in reply to Re: Re: Re: Re: Module to read a dumped file
in thread Module to read a dumped file
When you should be saying dump the hash as a referenceprint Dumper(%hash);
But as someone said, if you want to dump several top level vars and get them back in a list formprint Dumper(\%hash);
theres a few other tricks as well. You can parse out the var names from dumper then wrap them all in a do and return them as a list, yada yada.$dump= Data::Dumper->Dump([[\%hash,\@array,$scalar]],[qw(*vars)]); my @vars=eval $dump;
A last point. You may want to dump in Pruity=1 mode.
Be aware that seriously sick and twisted data structures dont dump properly with Data::Dumper. For this reason unless hand modification is needed of the dumped data you should use Storable instead. Also, evaling these structres from a file is a serious security risk (hostile code can be embedded in the file and will execute with your permissions when you eval it). Another good reason to use Storable (which has an easy to use reader too.)$Data::Dumper::Purity=1; print Data::Dumper->new([\%foo],['*foo'])->Purity(1)->Dump;
Anyway,
--- demerphq
my friends call me, usually because I'm late....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Module to read a dumped file
by juo (Curate) on Feb 12, 2003 at 15:12 UTC |