[pm-h] reading a file as a string
Russell L. Harris
rlharris at oplink.net
Sat May 19 19:25:44 PDT 2007
Is there a preferred approach for copying an entire file into a string
variable, while preserving the record delimiters (the newline
character)?
I have found two examples; is either of them a good approach?
open (FILE,$filename) || die "Cannot open '$filename': $!";
undef $/;
my $file_as_string = <FILE>;
open (FILE,$filename) || die "Cannot open '$filename': $!";
my $file_as_string = join '', <FILE>;
More information about the Houston
mailing list