-
-
Save anonymous/f28834b1050c46b9b792 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/lib/Mojo/Util.pm b/lib/Mojo/Util.pm | |
index 8983d3a..5cf74bd 100644 | |
--- a/lib/Mojo/Util.pm | |
+++ b/lib/Mojo/Util.pm | |
@@ -235,8 +235,8 @@ sub slurp { | |
my $path = shift; | |
open my $file, '<', $path or croak qq{Can't open file "$path": $!}; | |
- my $ret = my $content = ''; | |
- while ($ret = $file->sysread(my $buffer, 131072, 0)) { $content .= $buffer } | |
+ my ($ret, $content, $size) = ('', '', -s $file || 131072); | |
+ while ($ret = $file->sysread(my $buffer, $size, 0)) { $content .= $buffer } | |
croak qq{Can't read from file "$path": $!} unless defined $ret; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment