The array @pileofinchis is not declared as a lexical within the subroutine that you displayed to us. If it's safe for me to infer that variable is declared at a broader scope (or is a package global), whatever got pushed into it in the first call to the subroutine will still be there when you call the sub the second time and each subsequent time.
In my opinion, one of the worst things you can do with respect to subroutines is allow them to accept values through broader-scope "osmosis". My opinion is that all subroutine variables should be lexically scoped to the boundries of the subroutine. There are exceptions; closures for example. But you have to be careful whenever a value is passed to a sub via broader scope instead of via parameter list.
Dave
In reply to Re: Ghostly subroutine variables haunting me in subsequent calls
by davido
in thread Ghostly subroutine variables haunting me in subsequent calls
by moonunit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |