Permalink
Browse files

Merge pull request #33 from mhasch/master

improved a file slurp example in perlfaq5
  • Loading branch information...
2 parents 70f5c47 + cb99209 commit 68e64ae8132bc2f9f59140b0a8187cf12c4d9b38 @shlomif shlomif committed Jun 23, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/perlfaq5.pod
View
@@ -194,11 +194,11 @@ you can fit the whole thing in memory!):
open my $in, '<', $file or die "Can't read old file: $!"
open my $out, '>', "$file.new" or die "Can't write new file: $!";
- my @lines = do { local $/; <$in> }; # slurp!
+ my $content = do { local $/; <$in> }; # slurp!
# do your magic here
- print $out @lines;
+ print $out $content;
Modules such as L<File::Slurp> and L<Tie::File> can help with that
too. If you can, however, avoid reading the entire file at once. Perl

0 comments on commit 68e64ae

Please sign in to comment.