Storing texts from many files in an array using foreach Perl -
sub open_file { @files = @_; @file_text = (); foreach $file(@files){ open(my $fh, '<', "./data/" . $file) or die "can't open $file: $!"; @file_text = <$fh>; close($fh); } print "@file_text"; } having problems concatenating texts 3 different .html files 1 array @file_text
so far script stores text @file_text last .html file loops through.
of course, erase last value of @file_text each time line
@file_text = <$fh>; you should replace line
push (@file_text, <$fh>);
Comments
Post a Comment