in reply to Putting an array into a hash gives an unexpected reference to the hash itself.
G'day polarbear,
What you are describing is the default behaviour for Data::Dumper. You can change it by setting $Data::Dumper::Deepcopy:
$ perl -Mstrict -Mwarnings -e ' use Data::Dumper; $Data::Dumper::Deepcopy = 1; my @maintainers = qw/ worker@company.com manager@company.com /; my %services = ( service1 => { email => \@maintainers }, service2 => { email => \@maintainers }, ); print Data::Dumper->Dump( [ \%services ], [qw/*services/] ); ' %services = ( 'service1' => { 'email' => [ 'worker@company.com', 'manager@company.com' ] }, 'service2' => { 'email' => [ 'worker@company.com', 'manager@company.com' ] } );
Update: I may have misinterpreted "I don't want the lists connected in any way." as the cross-referencing of the lists output by Data::Dumper rather than the lists pointed to by the arrayrefs. If this is the case, the email => [ @maintainers ] solution would be the way to go. Thanks, frozenwithjoy.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Putting an array into a hash gives an unexpected reference to the hash itself.
by frozenwithjoy (Priest) on Nov 07, 2012 at 23:39 UTC | |
by kcott (Archbishop) on Nov 08, 2012 at 00:02 UTC |