in reply to Subroutine variables problem

Is there any chance that set_callback() hangs on to the first callbacks you pass for 'list' and 'status', and ignores subsequent attempts to set them? If so, those callbacks will reference variables in the stack frame of the first invocation of foldertree() and not the variables in the stack frames of recursive invocations. That is, you'd get the right number of references in the array, but the values in the referenced hashes would be bad.

You could verify this by adding a print to the 'status' callback, and then dump %folderhash right before you recurse. If the numbers don't match, then you'll need to make the callbacks reference package variables instead.

Replies are listed 'Best First'.
Re: Re: Subroutine variables problem
by Michalis (Pilgrim) on Oct 15, 2002 at 09:33 UTC
    I would be lying if I said that I had thought of that (or even that I understand the rationale behind that), but you are right. I did the tests you suggested and looked like there was a problem. After that I declared the variables global in the package (before the sub) and now it's working as expected (I Think :)
    Thanks for your valuable help.
    --
    Michalis