Reputation: 1235
I am new to perl. Anyhow I tried to debug myself. But I couldn't nail it
The syntax error is
Bareword found where operator expected at D:\DevelopmentLab\softwares\sc-master\sc.pl line 468, near "s%/%_%gr"
syntax error at D:\DevelopmentLab\softwares\sc-master\sc.pl line 468, near "s%/%_%gr"
Execution of D:\DevelopmentLab\softwares\sc-master\sc.pl aborted due to compilation errors.
The code is
sub getBackupFileName {
my ($containerName, $volume) = @_;
my $backupFileName = $volume =~ s%/%_%gr;
return "${containerName}_${backupFileName}.tar";
}
Any help would be highly appreciated..
Upvotes: 0
Views: 502
Reputation: 69314
The /r
option on s/.../.../
was added in Perl 5.14 (in 2011). If you're using an earlier version, your code won't work. I don't have an earlier version available to test on, so I can't tell for sure whether it would give the error message you're seeing.
The easiest fix to get this working on earlier versions of Perl would be something like this:
sub getBackupFileName {
my ($containerName, $volume) = @_;
(my $backupFileName = $volume) =~ s%/%_%g;
return "${containerName}_${backupFileName}.tar";
}
Upvotes: 9