|
|
| The stupid question is the question not asked | |
| PerlMonks |
Re: Using File::DosGlob::glob in loop only works first timeby Sandy (Curate) |
| on Feb 24, 2006 at 21:12 UTC ( [id://532722]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
The following tests were done on Solaris, using just the standard 'glob' as opposed to DosGlob.
First, my directories Now, use glob in scalar context, and it is apparent that it buffers it's output, to be sent back one at a time, regardless if it is called again with a new parameter. Do the same thing in list mode, and the list is 'refreshed' when a new glob is called. That said, you don't really need to use glob unless you use wildcards. I got bit once because I mistakenly believed that glob would always return files that only matched the inputs (with or without wildcards). In other words, the following is only true IF you use wildcards.
The first time you call glob, it returns the first filename that matches the file spec.If there are no wildcards in the parameter passed to glob, glob will simply return the string, even if the file does not exist. Notice that 'boo.txt' is not a valid file.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||