1#!./perl 2 3sub BEGIN { 4 unshift @INC, 't'; 5 unshift @INC, 't/compat' if $] < 5.006002; 6 require Config; import Config; 7 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { 8 print "1..0 # Skip: Storable was not built\n"; 9 exit 0; 10 } 11} 12 13use Storable (); 14use Test::More tests => 3; 15 16our $f; 17 18package TIED_HASH; 19 20sub TIEHASH { bless({}, $_[0]) } 21 22sub STORE { 23 $f = Storable::freeze(\$_[2]); 24 1; 25} 26 27package TIED_ARRAY; 28 29sub TIEARRAY { bless({}, $_[0]) } 30 31sub STORE { 32 $f = Storable::freeze(\$_[2]); 33 1; 34} 35 36package TIED_SCALAR; 37 38sub TIESCALAR { bless({}, $_[0]) } 39 40sub STORE { 41 $f = Storable::freeze(\$_[1]); 42 1; 43} 44 45package main; 46 47my($s, @a, %h); 48tie $s, "TIED_SCALAR"; 49tie @a, "TIED_ARRAY"; 50tie %h, "TIED_HASH"; 51 52$f = undef; 53$s = 111; 54is $f, Storable::freeze(\111); 55 56$f = undef; 57$a[3] = 222; 58is $f, Storable::freeze(\222); 59 60$f = undef; 61$h{foo} = 333; 62is $f, Storable::freeze(\333); 63 641; 65