tags:

views:

47

answers:

1

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.
+4  A: 

Put the my inside of the parenthesis...

(my $export = $doc) =~ s{\.odt}{.pdf};
Robert Wohlfarth