That is if you care about keeping the original contents - otherwise:my @array1 = qw/ball bat helmet/; while (@array1) { my $item = pop @array1; print $item; push(@array2,$item); }
my @array1 = qw/ball bat helmet/; while (@array1) { print pop @array1; }
In reply to Re: Printing an array using while loop
by perlfan
in thread Printing an array using while loop
by knapper19954
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |