http://www.perlmonks.org?node_id=11122691


in reply to What's happening in this expression?

Can you monks please explain step-by-step what computations will happen here?

Under strict, none, because it will not compile unless $x, $y, and $z have been previously declared. Otherwise, B::Deparse helps:

$ perl -MO=Deparse,-p -e 'my $a, $x, $y, $z = foo()' (my($a), $x, $y, ($z = foo()));

In other words, it's declaring a lexical $a, then $x and $y are simply sitting there, and then $z is assigned the return value of the function call foo() - although if that's not defined, that call will fail. See also Comma Operator. Turning on warnings gives some relatively helpful hints:

$ perl -w -e 'my $a, $x, $y, $z = foo()' Parentheses missing around "my" list at -e line 1. Useless use of a variable in void context at -e line 1. Useless use of a variable in void context at -e line 1. Name "main::x" used only once: possible typo at -e line 1. Name "main::z" used only once: possible typo at -e line 1. Name "main::y" used only once: possible typo at -e line 1. Undefined subroutine &main::foo called at -e line 1.