The stupid question is the question not asked | |
PerlMonks |
Re: Hi Monks could you pls help Perl dummy userby roboticus (Chancellor) |
on Dec 17, 2014 at 01:38 UTC ( [id://1110585]=note: print w/replies, xml ) | Need Help?? |
To illustrate what the Anonymous Monk above posted, here's a pair of functions, one of which is using a global (funky), and the other a local (monkey):
As you can see in the results below, the global variable $str1 got whacked, so has the same value after recursion for each level. The local value, however, retains its value, so can continue. The same thing is happening with your directory handle from readdir: When you recurse, you've clobbered the value, so you can't continue from that point. In fact, when the lowest level if your function is done, the directory handle is reporting "Nope, no more files" for each level on return.
Update: Immediately after posting, I realize that I didn't need two functions to illustrate it, the count variable is already localized, so the first function was enough. Ah, well. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|