Created
February 21, 2012 14:40
-
-
Save andrewrjones/1876882 to your computer and use it in GitHub Desktop.
Slurping text from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub slurp_from_file { | |
| my ( $self, $file ) = @_; | |
| return do { | |
| local $/ = undef; | |
| open my $fh, "<", $file | |
| or die "could not open $file: $!"; | |
| my $doc = <$fh>; | |
| # ensure there are no carriage returns | |
| $doc =~ s/(\r|\n)//g; | |
| return $doc; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment