in reply to Printing Stacks
Your @stack is just an array, and you want to see them in the reverse order:
print $stack[ $_ ] for reverse 0 .. $#stack;
And if you really want to destroy the stack in the process, add:
undef @stack;
You could also do:
print while pop @stack;
But that's just wasteful :) (It's actually not, perl's arrays are well optimised for this operation.)
|
|---|