Created
January 21, 2013 16:36
-
-
Save jberger/4587287 to your computer and use it in GitHub Desktop.
Data::Dumper + do for simple data storage
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
use Data::Dumper; | |
sub write_data { | |
my ($file, $data) = @_; | |
open my $fh, '>', $file or die "Couldn't open $file: $!"; | |
print $fh Dumper $data; | |
} | |
sub read_data { | |
my ($file) = @_; | |
my $data = do $file; | |
die $@ if $@; | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment