in reply to marshalling data
What Am I missing?
If you ask me, it depends on what you're trying to learn.
Consider
$ perl -MData::Dump -e " my@f=1..3;my@g=4..6;push@f,\@g;push@g,@f;dd\ +@f,\@g; " do { my $a = [1, 2, 3, [4, 5, 6, 1, 2, 3, 'fix']]; $a->[3][6] = $a->[3]; ($a, $a->[3]); }
Do you notice 'fix'? Do you notice how the self-referential-ness is established in a second step?
Employ Basic debugging checklist and compare that to your Dumper output
@data1 = ( 'one', 'won', [ 'two', 'too', 'to', \@data1 ] ); @data2 = @{$data1[2]};
How is it different from what you originally had? Different from my dd output?
The order of operations isn't the same, @data2 is set to the values of some anonymous array, as opposed to a reference to @data2 being pushed onto @data1 -- the two references will never be the same
Could there be an error in the book?
I wouldn't know, but I don't quite see the lesson its trying to teach -- DD isn't the greatest serialization tool, and string-eval isn't the greatest way to Undumper / Data::Undump
or perl?
Well no, but you could argue it's a bug in Data::Dumper-s prefix/varname feature
|
|---|