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.)
In reply to Re: Printing Stacks
by BrowserUk
in thread Printing Stacks
by drose2211
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |