stallion has asked for the wisdom of the Perl Monks concerning the following question:
Im currently learning perl and Im trying to open many text files and read the contents and extract a string from the files and the corresponding file name ...Th snippet im using is
@scriptfiles=glob('*.txt'); foreach my $file (@checkfiles) { open($file, "data.txt") or die("Unable to open file"); # read file into an array @data = <$file>; # close file close($file); foreach my $line(@data) { #print $line; if ($line =~ m/(Apple|Orange|Litchi)/) { $Sheet->Cells($row,$col-1)->{'Value'} = $file; $Sheet-> Cells($row,$col+6)->{'Value'} = $line ; $row=$row+1; }
I cant able to open the file and read the contents..pls rectify my mistake..
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: File Open Error
by aaron_baugher (Curate) on May 09, 2012 at 13:41 UTC | |
Re: File Open Error
by cdarke (Prior) on May 09, 2012 at 13:49 UTC | |
Re: File Open Error
by Anonymous Monk on May 09, 2012 at 13:23 UTC | |
by Anonymous Monk on May 09, 2012 at 13:32 UTC | |
Re: File Open Error
by BillKSmith (Monsignor) on May 09, 2012 at 14:08 UTC |