CW Holeman II
CW Holeman II

Reputation: 4961

Perl compile error on: "my ($export = $doc) =~ s{\.odt}{\.pdf};"

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

Answers (1)

Robert Wohlfarth
Robert Wohlfarth

Reputation: 1771

Put the my inside of the parenthesis...

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

Upvotes: 4

Related Questions