Set $Data::Dumper::Deepcopy to true before dumping.
#!/usr/bin/env perl use Data::Dumper; use strict; use warnings; my %hash=("one two"=>"buckle my shoe","three four"=>"shut the door"); my @arrayOfHashes; for (1..3) { push @arrayOfHashes,\%hash; } warn 'BEFORE: ',Data::Dumper->Dump([\@arrayOfHashes],[qw(*arrayOfHashe +s)]),' '; $Data::Dumper::Deepcopy=1; warn 'AFTER: ',Data::Dumper->Dump([\@arrayOfHashes],[qw(*arrayOfHashes +)]),' ';
BEFORE: @arrayOfHashes = ( { 'one two' => 'buckle my shoe', 'three four' => 'shut the door' }, $arrayOfHashes[0], $arrayOfHashes[0] ); at DataDumperDeepCopy.t line 12. AFTER: @arrayOfHashes = ( { 'one two' => 'buckle my shoe', 'three four' => 'shut the door' }, { 'one two' => 'buckle my shoe', 'three four' => 'shut the door' }, { 'one two' => 'buckle my shoe', 'three four' => 'shut the door' } ); at DataDumperDeepCopy.t line 14.
In reply to Re: Push array to hash
by clueless newbie
in thread Push array to hash
by bartrad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |