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:
Questions:perl -e 'for $i (1..9){print "Next", next if $i == 5;print $i}' Output: 12346789
Thank you!
tel2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple commands separated by commas
by BrowserUk (Patriarch) on Sep 01, 2011 at 06:14 UTC | |
|
Re: Multiple commands separated by commas
by JavaFan (Canon) on Sep 01, 2011 at 06:24 UTC | |
|
Re: Multiple commands separated by commas
by Marshall (Canon) on Sep 03, 2011 at 04:38 UTC | |
|
Re: Multiple commands separated by commas
by tel2 (Pilgrim) on Sep 08, 2011 at 00:12 UTC | |
|
Re: Multiple commands separated by commas
by tel2 (Pilgrim) on Sep 01, 2011 at 22:43 UTC |