Give a better error message if writeFile fails due to permission issues

This commit is contained in:
Eelco Dolstra 2012-12-20 12:22:13 +01:00
parent e775d4d84f
commit 9c29a2ed35
1 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ sub uniq {
sub writeFile { sub writeFile {
my ($fn, $s) = @_; my ($fn, $s) = @_;
open TMP, ">$fn" or die; open TMP, ">$fn" or die "cannot create file `$fn': $!";
print TMP "$s" or die; print TMP "$s" or die;
close TMP or die; close TMP or die;
} }
@ -31,7 +31,7 @@ sub writeFile {
sub readFile { sub readFile {
local $/ = undef; local $/ = undef;
my ($fn) = @_; my ($fn) = @_;
open TMP, "<$fn" or die; open TMP, "<$fn" or die "cannot open file `$fn': $!";
my $s = <TMP>; my $s = <TMP>;
close TMP or die; close TMP or die;
return $s; return $s;