diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-18 23:10:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-18 23:10:57 +0000 |
commit | 40b4b6e177c62a14c166dbba6adf3abc415af4b2 (patch) | |
tree | 2996bf29509c806bd8064fb6cf38092c1b375ff8 /Master/tlpkg/tlperl/lib/Storable.pm | |
parent | 8e743c86b6872f30b7a35c72aa944455157d4b3f (diff) |
tlperl 5.24.1 from siep
git-svn-id: svn://tug.org/texlive/trunk@43914 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Storable.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/Storable.pm | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/Master/tlpkg/tlperl/lib/Storable.pm b/Master/tlpkg/tlperl/lib/Storable.pm index bd0632f832d..5823b930b8d 100644 --- a/Master/tlpkg/tlperl/lib/Storable.pm +++ b/Master/tlpkg/tlperl/lib/Storable.pm @@ -22,10 +22,16 @@ package Storable; @ISA = qw(Exporter); use vars qw($canonical $forgive_me $VERSION); -$VERSION = '2.53_01'; +$VERSION = '2.56_01'; BEGIN { - if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) { + if (eval { + local $SIG{__DIE__}; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + require Log::Agent; + 1; + }) { Log::Agent->import; } # @@ -979,43 +985,43 @@ such. Here are some code samples showing a possible usage of Storable: - use Storable qw(store retrieve freeze thaw dclone); + use Storable qw(store retrieve freeze thaw dclone); - %color = ('Blue' => 0.1, 'Red' => 0.8, 'Black' => 0, 'White' => 1); + %color = ('Blue' => 0.1, 'Red' => 0.8, 'Black' => 0, 'White' => 1); - store(\%color, 'mycolors') or die "Can't store %a in mycolors!\n"; + store(\%color, 'mycolors') or die "Can't store %a in mycolors!\n"; - $colref = retrieve('mycolors'); - die "Unable to retrieve from mycolors!\n" unless defined $colref; - printf "Blue is still %lf\n", $colref->{'Blue'}; + $colref = retrieve('mycolors'); + die "Unable to retrieve from mycolors!\n" unless defined $colref; + printf "Blue is still %lf\n", $colref->{'Blue'}; - $colref2 = dclone(\%color); + $colref2 = dclone(\%color); - $str = freeze(\%color); - printf "Serialization of %%color is %d bytes long.\n", length($str); - $colref3 = thaw($str); + $str = freeze(\%color); + printf "Serialization of %%color is %d bytes long.\n", length($str); + $colref3 = thaw($str); which prints (on my machine): - Blue is still 0.100000 - Serialization of %color is 102 bytes long. + Blue is still 0.100000 + Serialization of %color is 102 bytes long. Serialization of CODE references and deserialization in a safe compartment: =for example begin - use Storable qw(freeze thaw); - use Safe; - use strict; - my $safe = new Safe; + use Storable qw(freeze thaw); + use Safe; + use strict; + my $safe = new Safe; # because of opcodes used in "use strict": - $safe->permit(qw(:default require)); - local $Storable::Deparse = 1; - local $Storable::Eval = sub { $safe->reval($_[0]) }; - my $serialized = freeze(sub { 42 }); - my $code = thaw($serialized); - $code->() == 42; + $safe->permit(qw(:default require)); + local $Storable::Deparse = 1; + local $Storable::Eval = sub { $safe->reval($_[0]) }; + my $serialized = freeze(sub { 42 }); + my $code = thaw($serialized); + $code->() == 42; =for example end |