in reply to perl statements
In scalar context, the comma operator separates expressions and returns the evaluation of the rightmost expression. Here, the first expression is evaluated and the result discarded; the side-effect of incrementing $names remains.$names++, shift if ARGV[0] eq "-l";
Update: It should be noted that no list is created by a series of comma operators in scalar context. The expressions operated on by the commas become subexpressions.
The second construct is similar but I find it odder.
The same thing is happening; the assignments are in scalar context. I'd write this with a semi-colon in the middle of the do's block; one standard use of the do BLOCK is to wedge a statement or statements into a place that needs an expression. If $c were @c, my semi-colon would change the meaning.$c = do { $a = 3, $b = 6 };
Be well,
rir
|
|---|