in reply to is it possible to create image out of all variables in perl script ?
Remember that Storable can store only one variable so if you need more than one you need to do something like:
my ($fruit, $none, $arr, $drink) = @{retrieve('store-test.sto')}; (credit to kcott)
Consider this example that just retrieve vars from file:
use Storable qw(nstore retrieve); # these are the vars replaced by load_from_file my %conf = (a=>'A',b=>'B'); my %help = (a=>'letter A',b=>'letter B'); load_from_file('/path/to/file.sto'); sub load_from_file { my $file = shift; unless (defined $file){ return ; } my $pfile = File::Spec->catfile($drive,$directories,'conf',$file); if (defined $file && -e $pfile) { my $mconf; my $mhelp; eval {($mconf, $mhelp )= @{retrieve ($pfile)}} ; if ($@){ warn "WARNING no configuration in '$file'!\n"; return +;} else { %conf = %{$mconf}; %help = %{$mhelp}; print "OK $file profile loaded.\n"; return 1; } } else {warn "WARNING profile $file not found!\n";return} }
L*
|
|---|