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} }