Reputation: 4961
Based upon SO answer "my ($export = $doc) =~ s{.odt}{.pdf};" why does this Perl script produce a compile error?
$ cat so.pl
#!/usr/bin/perl
my $doc ="x.odt";
my ($export = $doc) =~ s{\.odt}{.pdf};
$ ./so.pl
Can't declare scalar assignment in "my" at ./so.pl line 3, near ") =~"
Execution of ./so.pl aborted due to compilation errors.
Upvotes: 1
Views: 204
Reputation: 1771
Put the my inside of the parenthesis...
(my $export = $doc) =~ s{\.odt}{.pdf};
Upvotes: 4