If you need to reverse the contents of the array and you don't want to use the reverse function, you could do something like this:
use strict; use warnings; my @foo = @ARGV; # get the array we're reversing # reverse it: my @tempfoo; while (scalar (@foo)) { my $element = pop (@foo); push @tempfoo, $element; } @foo = @tempfoo; # foo has been reversed...
There are probably a hundred different ways to do it if you want to do it just to do it. But stick with reverse unless you absolutely don't want to. It's much cleaner and easier to understand.
In reply to Re: pop an array
by Vautrin
in thread pop an array
by JayBee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |