I have a hash of arrays that I'd like to use as stacks. Initially, the arrays are empty. Later in my code, I'm using one of these stacks at a time for some processing.
What I'd like to do is set a temporary reference equal to the result of the hash lookup and perform operations on that since this will eliminate unnecessary lookups and make my code a little less disgusting.
The problem I am having is that when I assign a reference to an undefined list, the modifications I make are not reflected. As soon as I add an element to the original list, everything works as expected. This would make sense if perl's hard references don't do anything special for undefined references.
Currently, I could do something really cheezy, like pushing and then popping once from each list at the start (which would create empty but "defined" arrays), but this doesn't seem particularly robust since this might change in the next perl revision.
So, is there a good way to create an array of size 0 that is also defined? Would using soft references fix this problem?
Please enlighten this humble novice, oh great perl monks.
In reply to creating defined references to arrays of size zero by spieper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |