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

View file

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