It was a small surprise to me, therefore, that [local $fred = $fred ? "Still $fred" : 'undef' ;] sets $fred to 'Still 78'
Although it's not documented, all Perl operators except assignment operators evaluate their operands in left-to-right order. Assignment operators evaluate their RHS before their LHS.
sub d :lvalue { print("$_[0]\n"); $_[1] } d("LHS", 4 ) + d("RHS", 5); # LHS, RHS d("LHS", $var) = d("RHS", 1); # RHS, LHS
This was specifically done to handle expressions of the form f($var) = g($var). That's why $x = $x + 1 works. That's why my $x = $x; works.
which leaves me wondering where the contradiction is
Sorry, I missed the bold portion in "This second turns out to be essential in order to use local to automatically restore the $SIG state on forced exit (die) from an eval."
In reply to Re^9: Setting signal handlers considered unsafe?
by ikegami
in thread Setting signal handlers considered unsafe?
by gnosek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |