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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -