only reading every other directory



A very peculiar (to me) behavior has been observed when I run a simple script,
and I wanted to get some other eyes looking at it. I have a directory called
"Good", and subdirectories "01", "02", ... "05". In each directory is a
single file, "01.dat", "02.dat" etc. All I want to do (for now) is to find
and print the name of the dat files. Simple, yes? So I do this:

use strict;
use warnings;
my @dirs=<Good/*>; #get the directories
my ($i,$datfile);
print "@dirs\n"; #print the directories
for $i(0..scalar(@dirs)-1){
print $i+1,"\t$dirs[$i]\t"; #print some sanity checks
$datfile=<$dirs[$i]/*>; #get the name of the dat file
print "$datfile\n"; # and print it
}

and I get the following results:
$ perl test.pl
Good/01 Good/02 Good/03 Good/04 Good/05
1 Good/01 Good/01/01.dat
Use of uninitialized value in concatenation (.) or string at test.pl line 9.
2 Good/02
3 Good/03 Good/03/03.dat
Use of uninitialized value in concatenation (.) or string at test.pl line 9.
4 Good/04
5 Good/05 Good/05/05.dat

The result is that it found all the directories, but it only finds the dat
file in directories 1,3, and 5, not 2 and 4. The warning doesn't really tell
me anything that I didn't already know. To make sure I am not crazy, I do:

$ ls Good/0?/*.dat
Good/01/01.dat Good/02/02.dat Good/03/03.dat Good/04/04.dat Good/05/05.dat

Any ideas?

thanks,
Derek
.



Relevant Pages

  • Re: syntax...
    ... B&D on the part of the language designer. ... probably handle concatenation of string literals by itself, ... bitwise XOR, or if not that, then exponentiation.) ...
    (comp.lang.misc)
  • Bugs in the Module::Dependency
    ... Manifying blib/man1/pmd_indexer.plx.1 ... Use of uninitialized value in concatenation or string at ... # Failed test in t/04grapher.t at line 81. ...
    (perl.dbi.users)
  • RE: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ...
    (perl.beginners)
  • Re: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ./magic.pl ...
    (perl.beginners)
  • Re: a nice little perl utility
    ... Use of uninitialized value in concatenation or string at jabba5.pl ... How did this have to do with the print statement? ... # Fetch overview information for the articles ...
    (comp.lang.perl.misc)