Skip to content

Instantly share code, notes, and snippets.

@andrewrjones
Created February 21, 2012 14:40
Show Gist options
  • Select an option

  • Save andrewrjones/1876882 to your computer and use it in GitHub Desktop.

Select an option

Save andrewrjones/1876882 to your computer and use it in GitHub Desktop.
Slurping text from a file
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