in reply to arrays: shifting in while loop
This is how Perl is interpreting the critical line of your code:
C:\test>perl -MO=Deparse,p -e" print (shift @a), (shift @a), "\n";" print(shift @a), shift @a, \'n'; -e syntax OK
As you can see, only the first parameter is being passed to print.
If you add another set of parens:
print( (shift @a), (shift @a), "\n" );
Or drop the parens entirely:
print shift @a, shift @a, "\n";
Your code will (probably) work as you expect.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: arrays: shifting in while loop
by ivanthemad (Initiate) on Mar 06, 2012 at 14:47 UTC | |
by kcott (Archbishop) on Mar 06, 2012 at 15:09 UTC | |
by Anonymous Monk on Mar 06, 2012 at 14:50 UTC | |
by JavaFan (Canon) on Mar 06, 2012 at 15:07 UTC |