for (my $n = 0; $n <= scalar(@a); $n++) { ... }
Note the change in operator - Your code was only doing one iteration through the loop while $n was less than 1 and not less than or equal to 1. As such, it was only iterating through the loop once and setting $b[0] and not $b[1] - If you had more values in @a, you would have found it iterating through and acting on all except the last value.
Ooohhh, Rob no beer function well without!
In reply to Re: sprintf and for loop weirds???
by rob_au
in thread sprintf and for loop weirds???
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |