in reply to Coming across an issue with glob. Is only able to find every other directory.
The problem is that you’re calling glob in scalar context, but expecting it to behave as if called in list context. See I/O Operators:
A (file)glob evaluates its (embedded) argument only when it is starting a new list. All values must be read before it will start over. In list context, this isn't important because you automatically get them all anyway. However, in scalar context the operator returns the next value each time it's called, or undef when the list has run out. ... So if you're expecting a single value from a glob, it is much better to say
($file) = <blurch*>;than
$file = <blurch*>;because the latter will alternate between returning a filename and returning false.
Update: I don’t have a Solaris box, but on Windows I created two directories: ...\666_SoPW\home\vize\units\11780540\moving_code_AFT and ...\666_SoPW\home\vize\units\91540670\moving_code_INT and ran the OP code, with the following result:
12:25 >perl 666_SoPW.pl 11780540 good Use of uninitialized value $moving_code_dir in split at 666_SoPW.pl li +ne 41. 91540670 bad 12:25 >
I then changed the line:
my $moving_code_dir = glob("$UNIT_DIR/$unit/moving_code_*");
to
my ($moving_code_dir) = glob("$UNIT_DIR/$unit/moving_code_*");
as per the documentation quoted above, and the output is:
12:25 >perl 666_SoPW.pl 11780540 good 91540670 good 12:26 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|