in reply to Its not supposed to!
For example, suppose /tmp contains:
On the first recursion, the parent directory is /tmp. The glob picks up chromatic/ and isotope/. @dirs is empty./tmp/chromatic /tmp/isotope
It recurses to chromatic/ and picks up a bunch of files there, but none are directories. It returns the empty @dirs. That brings us to the push, and we put chromatic/ into @dirs.
Next, it moves on to isotope/. @dirs contains only chromatic/. As there are only files in isotope/, it doesn't push anything. It returns @dirs (still containing chromatic/) and then reaches the point where it pushes isotope/ onto the array.
As there is nothing left to check from the glob, it returns @dirs, now containing chromatic/ and isotope/. Recursion and global variables are subtle this way.
It's the push statement that makes it right. If you only did an assignment to @dirs, it would be wrong.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Its not supposed to!
by BBQ (Curate) on Apr 18, 2000 at 04:57 UTC | |
by chromatic (Archbishop) on Apr 18, 2000 at 06:19 UTC |