in reply to Using File::DosGlob::glob in loop only works first time
When using glob in a scalar context, you must loop until it returns undef. Compare
use strict; use warnings; use File::DosGlob 'glob'; $| = 1; for (1..2) { my $glob = glob($0); print($glob, "\n"); } __END__ script.pl Use of uninitialized value in print at script.pl line 11.
with
use strict; use warnings; use File::DosGlob 'glob'; $| = 1; for (1..2) { while (defined(my $glob = glob($0))) { print($glob, "\n"); } } __END__ script.pl script.pl
That said, I'm not sure why you're using glob at all if you only look at the first element. Why not just do unless ( -f $template_file )?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using File::DosGlob::glob in loop only works first time
by ff (Hermit) on Feb 24, 2006 at 19:07 UTC | |
by ikegami (Patriarch) on Feb 24, 2006 at 21:46 UTC | |
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 | |
|