Permalink
Browse files

adding lib/Dist/Surveyor/DB_File.pm

  • Loading branch information...
1 parent 6db8bc7 commit 677e80ebe9b2ec0953fb2b610f3c509a097584a0 @semuel committed Oct 18, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/Dist/Surveyor/DB_File.pm
@@ -0,0 +1,19 @@
+package Dist::Surveyor::DB_File;
+use base 'DB_File';
+use Storable qw(freeze thaw);
+
+# DB_File can store only strings as values, and not Perl structures
+# this small wrapper fixes the problem
+
+sub STORE {
+ my ($self, $key, $val) = @_;
+ $self->SUPER::STORE($key, freeze($val));
+}
+
+sub FETCH {
+ my ($self, $key) = @_;
+ my $val = $self->SUPER::FETCH($key);
+ return thaw($val);
+}
+
+return 1;

0 comments on commit 677e80e

Please sign in to comment.