in reply to Re: weird error message in middle-aged-perl(5.14)
in thread weird error message in middle-aged-perl(5.14)
Running the following program under ActiveState 5.8.9 and Strawberries 5.10/12/14 (all Win32) gives me identical results:
c:\@Work\Perl>perl -wMstrict -le "my $x = 0; my $y; ;; sub S :lvalue { if ($x) { $y; } } ;; S() = 'foo'; ;; print qq{x '$x' y '$y'}; " Can't modify logical and (&&) in lvalue subroutine return at -e line 1 +, near "} }" Execution of -e aborted due to compilation errors.
Given the experimental nature of :lvalue trumpeted in the Lvalue subroutines section of perlsub, I would be very reluctant to use it with a complex subroutine. If the Perl compiler can't even figure out the simple example code above, what hope for the vipers' nest of conditionals that is the _Var() workhorse?
(Somewhere in the back of my mind is something about the compiler sometimes optimizing a statement like
if ($x) { do_this(); };
to
$x && do_this();
so this may be part of the problem — but don't quote me on this!
Update: Actually, it's $y if $x; that is so optimized/compiled, using and not &&. Nevermind...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: weird error message in middle-aged-perl(5.14)
by perl-diddler (Chaplain) on May 09, 2014 at 05:10 UTC |