http://www.perlmonks.org?node_id=969627


in reply to File Open Error

Did you notice there were a few syntax errors?
You probably meant something like this:
foreach my $file (glob('*.txt')) { open(my $fh, $file) or die("Unable to open '$file': $!"); while (my $line = <$fh>) { if ($line =~ m/(Apple|Orange|Litchi)/) { $Sheet->Cells($row,$col-1)->{'Value'} = $file; $Sheet->Cells($row,$col+6)->{'Value'} = $line ; $row=$row+1; } } # close file close($fh); }