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
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>