Looping between file to store text Perl -
sub open_file { @files = @_; @file_text = (); foreach $file(@files){ open(my $fh, '<', $file); @file_text = <$fh>; close($fh); } return @file_text; }
hi there. there seems problem coding particularly foreach
loop part. @files
array containing @files = (abc.html bcd.htm zxy.html);
open these html files , store accumulative html texts in @file_text
further use.
however getting error :
readline() on closed filehandle $fh @ source-1-2.pl line 36 readline() on closed filehandle $fh @ source-1-2.pl line 36 readline() on closed filehandle $fh @ source-1-2.pl line 36
maybe getting 3 line of same error cause looping between 3 html/htm files.
perhaps check if open
succeeded:
open(my $fh, '<', $file) or die "can't open $file: $!";
Comments
Post a Comment