in reply to Printing an array using while loop
or:
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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Printing an array using while loop
by AnomalousMonk (Archbishop) on May 19, 2020 at 23:18 UTC |
In Section
Seekers of Perl Wisdom