Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Multiple commands separated by commas

by Marshall (Prior)
on Sep 03, 2011 at 04:38 UTC ( #923961=note: print w/ replies, xml ) Need Help??

in reply to Multiple commands separated by commas

The comma operator can be complicated.
I would not use the comma operator in this complex of a situation.

If there are multiple parts, put () around the comma parts(eg (part1), (part2,)) and it will parse like you expect.

#!usr/bin/perl -w use strict; for my $i (1..9) { (print "Next"), next if $i == 5; print $i } __END__ Output: 1234Next6789
Another what I think is better coding (don't use the comma if not needed):
#!usr/bin/perl -w use strict; for my $i (1..9) { if ($i == 5) { print "Next"; next; } print $i; } __END__ Output: 1234Next6789
The basic thing with the comma operator, is that what appears in the last part of the comma statement is what matters.

Comment on Re: Multiple commands separated by commas
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://923961]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-12-28 06:46 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (179 votes), past polls