in reply to reading files from a directory
while ( < IN > ){
To:
while ( <IN> ){
B::Deparse can shine a little more light upon the situation (Tip #6 from the Basic debugging checklist):
perl -MO=Deparse 867882.pl my $dir = 'input_files'; die "can't opendir $!" unless opendir DIR, $dir; while (defined(my $file = readdir DIR)) { do { print "The directory and file are $dir/$file\n"; die "Can't open input file $!" unless open IN, "< $dir/$file"; use File::Glob (); while (defined($_ = glob(' IN '))) { print $_; } }; } closedir DIR;
Here is an explanation from perlop:
Even <$x > (note the extra space) is treated as glob("$x ") , not readline($x).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading files from a directory
by kevyt (Scribe) on Oct 28, 2010 at 05:49 UTC | |
|
Re^2: reading files from a directory
by kevyt (Scribe) on Oct 28, 2010 at 06:01 UTC | |
by kcott (Archbishop) on Oct 28, 2010 at 06:34 UTC |