Permalink
Browse files

Check status when closing $fh on file (de)serialization

  • Loading branch information...
1 parent 1d6bada commit 4253fbb91168802789b3cdd6cc2abd460c8b7a75 @caio committed May 2, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Data/FlexSerializer.pm
@@ -205,6 +205,8 @@ sub deserialize_from_file {
open my $fh, '<', $file;
local $/;
my $data = <$fh>;
+ close $fh or die "Error closing file handle: $!";
+
my ($rv) = $self->deserialize($data);
return $rv;
}
@@ -220,7 +222,7 @@ sub serialize_to_file {
open my $fh, '>', $file;
print $fh $self->serialize($data);
- close $fh;
+ close $fh or die "Error closing file handle: $!";
return 1;
}

0 comments on commit 4253fbb

Please sign in to comment.