http://qs321.pair.com?node_id=687892


in reply to Treating the file contents of a text file as a string

From analyzing your question I'd assume that you try to handle the content of each file as a string for itself (no concatenation).

About one month ago you asked almost the same question w/different wording.

Please do give us some more words of "problem description" next time ;-)

(My interpretation of your question follows:)

my ($filename1, $filename2) = qw( adaykin1.txt adaykin2.txt ); my @string; for my $fn ($filename1, $filename2) { # iterate over given file +names open my $fh, '<', $fn or die "$fn - $!"; # open each file local $/; push @string, <$fh> # read it into one string } # print $string[0]; # first file as one big string print $string[1]; # second file as one big string ...

Regards

mwa

Replies are listed 'Best First'.
Re^2: Treating the file contents of a text file as a string
by adaykin31 (Novice) on May 22, 2008 at 17:14 UTC
    Well it wasn't the same question. Read the last one again and you'll see. What I meant in this question was to read every single character in a file and save every single character in the file into one string. And yes the File::Slurp was exactly what I was looking for this time. Code is working perfectly now, thanks!