in reply to Re^2: Using File::DosGlob::glob in loop only works first time
in thread Using File::DosGlob::glob in loop only works first time
I'm using glob in case the absolute path names contain a space character somewhere.
How does glob help you with path names that have spaces? glob accepts a file spec (i.e. something with *) and returns all matching files. It's used to allow the user to specify multiple files at once. However, since you're only interested in one file, it makes no sense to accept file specs or to use glob.
-f works with spaces, whether you've passed the value through glob or not.
The thing that's bothering me about this is "Why does glob give me a valid answer for the first item in my list, even when I'm using it in scalar context, and not the second?"
When glob is called in a scalar context, it still returns all the values it would in a list context. It just returns one by one. Somehow, it has to tell you when it's done returning all the values. It does that by returning undef.
The first time you call glob, it returns the first filename that matches the file spec.
The second time you call glob, it returns undef since there are are no files that match the file spec passed to the first call to glob.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using File::DosGlob::glob in loop only works first time
by ff (Hermit) on Feb 24, 2006 at 22:21 UTC | |
by ikegami (Patriarch) on Feb 25, 2006 at 06:30 UTC | |
by ff (Hermit) on Feb 25, 2006 at 22:59 UTC | |
by ikegami (Patriarch) on Feb 26, 2006 at 00:12 UTC |