Perl编译错误:“my($ export = $ doc)=〜s {\。odt} {\。pdf};”

时间:2010-06-02 15:09:51

标签: perl

基于SO回答“my ($export = $doc) =~ s{.odt}{.pdf};”为什么这个Perl脚本会产生编译错误?

$ 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.

1 个答案:

答案 0 :(得分:4)

my 放在括号内...

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