From c9f8a8aa21c2804701d678afe5d05512df789617 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 11 Jul 2009 18:06:30 +0200 Subject: Don't export any functions by default --- lib/Simplestore.pm | 14 +++++++++----- t/simplestore.t | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/Simplestore.pm b/lib/Simplestore.pm index af5aaf0..11d8058 100644 --- a/lib/Simplestore.pm +++ b/lib/Simplestore.pm @@ -9,7 +9,7 @@ use Carp; our (@ISA, @EXPORT, $VERSION); require Exporter; @ISA = ('Exporter'); -@EXPORT = ('load', 'save'); +@EXPORT = (); $VERSION = '1.0'; sub load { @@ -60,12 +60,12 @@ Simplestore - simple storage format for hash refs # somefile contains: # word purrl # foo eggs - my $hash = load('somefile'); + my $hash = Simplestore::load('somefile'); say $hash->{word}; # purrl $hash->{foo} = 'bar'; $hash->{sentence} = "Mind the\nnewnile.; - save('somefile', $hash); + Simplestore::save('somefile', $hash); # somefile contains: # word purrl @@ -83,9 +83,13 @@ References or any other complex stuff is not supported. =head1 FUNCTIONS +Note: The function names are quite generic, so by default they are not +exported. Use C<< use Simplestore qw/load save/ >> if you want to use them +directly. + =over -=item B(I[, I]) +=item B(I[, I]) Load the hash saved in I. Returns a hash ref containing the hash saved in I. @@ -93,7 +97,7 @@ saved in I. If I is specified, I will not be loaded into an empty hash, but into I. However, keys in I overwrite those in I. -=item B(I, I) +=item B(I, I) save I in I. Returns nothing. diff --git a/t/simplestore.t b/t/simplestore.t index 3c35f83..b6c30a3 100644 --- a/t/simplestore.t +++ b/t/simplestore.t @@ -13,18 +13,18 @@ BEGIN {use_ok('Simplestore')} require_ok('Simplestore'); $hash = {foo => "bar\nbar"}; -ok(save($testfile, $hash), 'save hash 1'); +ok(Simplestore::save($testfile, $hash), 'save hash 1'); undef $hash; -ok($hash = load($testfile), 'load hash 1'); +ok($hash = Simplestore::load($testfile), 'load hash 1'); is($hash->{foo}, "bar\nbar", 'successful storage & load'); $hash = {dude => "dudette\nfoo"}; -$hash = load($testfile, $hash); +$hash = Simplestore::load($testfile, $hash); is($hash->{dude}, "dudette\nfoo", 'load: preserve hash keys'); $hash = {foo => "moose\nbaz"}; -$hash = load($testfile, $hash); +$hash = Simplestore::load($testfile, $hash); is($hash->{foo}, "bar\nbar", 'load: overwrite conflicting hash keys'); unlink($testfile); -- cgit v1.2.3