Get rid of the whitespace surrounding your IN filehandle.
Change:
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).