throop has asked for the wisdom of the Perl Monks concerning the following question:
I'm used to serializing with Data::Dumper. It produces a dump string which, when loaded, sets variables to values. E.g:
givesuse Data::Dumper; @arg2 = [{a => 1, b =>2}], [qw($balloon)]; Data::Dumper->Dump(@arg2)
When that's printed to a file, and later loaded, $balloon gets set right. But for YAML:'$balloon = { \'a\' => 1, \'b\' => 2 };
givesuse YAML::XS; @arg2 = ([{a => 1, b =>2}], [qw($balloon)]); Dump(@arg2)
which, when loaded, gives,'--- - a: 1 b: 2 --- - $balloon '
Should I just use eval to get $balloon set to the right value? Or is there a YAML function to do this?0 ARRAY(0x89889e8) 0 HASH(0x8994130) 'a' => 1 'b' => 2 1 ARRAY(0x8ef27c8) 0 '$balloon'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Serialization and eval in YAML
by Anonymous Monk on Aug 13, 2012 at 17:15 UTC | |
|
Re: Serialization and eval in YAML
by thundergnat (Deacon) on Aug 13, 2012 at 18:15 UTC | |
by Anonymous Monk on Aug 13, 2012 at 20:27 UTC |