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

tel2 has asked for the wisdom of the Perl Monks concerning the following question:

Dearly beloved Monks,

We are gathered here today to try to help me understand what kinds of commands can be strung together with commas, and what kinds can't, for concise coding.

For example, this works as I would expect (i.e. $x gets the value of $i before the "next" command occurs:

perl -e 'for $i (1..9){$x = $i, next if $i == 5;print $i};END{print "\ +n$x\n"}' Output: 12346789 5

But here, I would have expected "Next" to print, but as you can see, it doesn't:

perl -e 'for $i (1..9){print "Next", next if $i == 5;print $i}' Output: 12346789
Questions:
1. Why does '$x = $i' get executed, but 'print "Next"' seems not to, in the above examples?
2. Why didn't I get some kind of error/warning (still nothing even with the '-w' switch), in my 2nd example?
3. Where can I read up about which kinds of commands can be strung together with commas, and which can't?

Thank you!
tel2