Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Multiple commands separated by commas

by Marshall (Monsignor)
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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2016-06-25 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (322 votes). Check out past polls.