Navigation Menu

Skip to content

Commit

Permalink
fixed small portability bugs in slurp and spurt functions of Mojo::Util
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 30, 2013
1 parent a4aa654 commit 1b6ae7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@
4.08 2013-05-30
- Improved Mojo::Message::Request to allow curly brackets in URLs.
- Improved HMAC-SHA1 performance in Mojo::Util.
- Fixed small portability bugs in slurp and spurt functions of Mojo::Util.

4.07 2013-05-26
- Updated jQuery to version 2.0.1.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -238,15 +238,15 @@ sub sha1_sum { sha1_hex(@_) }
sub slurp {
my $path = shift;
croak qq{Can't open file "$path": $!} unless open my $file, '<', $path;
croak qq{Can't open file "$path": $!} unless open my $file, '<:raw', $path;
my $content = '';
while ($file->sysread(my $buffer, 131072, 0)) { $content .= $buffer }
return $content;
}

sub spurt {
my ($content, $path) = @_;
croak qq{Can't open file "$path": $!} unless open my $file, '>', $path;
croak qq{Can't open file "$path": $!} unless open my $file, '>:raw', $path;
croak qq{Can't write to file "$path": $!}
unless defined $file->syswrite($content);
return $content;
Expand Down

0 comments on commit 1b6ae7c

Please sign in to comment.