in reply to Re^11: Merge hashes in specific format
in thread Merge hashes in specific format
But it won't work because when I pass $final_href to this sub, it is empty, so it will fail "Can't use an undefined value as a HASH reference"my ($name,$dirs,$final_href) = @_; my %data; foreach my $dir (@{$dirs}) { decode($dir."/".$name,%data); # will change name my $final_href = ( data => { ( %{$final_href->{data} },%{ $data{data} } ) }, total => do { my %total; for my $href ( $final_href->{total}, $data{total} ) { $total{$_} += $href->{total}{$_} for keys %{ $href->{ +total} }; } \%total; } ); }
But it also does not work. it wants a real hash (because we do dereferencing with %{$final_href->{data}).$files_href->{data} = (); $files_href->{total} = ();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: Merge hashes in specific format
by tybalt89 (Monsignor) on Jan 13, 2019 at 00:41 UTC | |
by ovedpo15 (Pilgrim) on Jan 13, 2019 at 00:46 UTC | |
by LanX (Saint) on Jan 13, 2019 at 00:48 UTC | |
|
Re^13: Merge hashes in specific format
by pryrt (Abbot) on Jan 13, 2019 at 00:44 UTC | |
by ovedpo15 (Pilgrim) on Jan 13, 2019 at 01:00 UTC | |
by hippo (Archbishop) on Jan 13, 2019 at 11:07 UTC | |
by tybalt89 (Monsignor) on Jan 13, 2019 at 01:14 UTC | |
by ovedpo15 (Pilgrim) on Jan 13, 2019 at 01:46 UTC | |
by LanX (Saint) on Jan 13, 2019 at 02:13 UTC | |
by pryrt (Abbot) on Jan 13, 2019 at 19:28 UTC | |
by LanX (Saint) on Jan 13, 2019 at 01:20 UTC | |
by ovedpo15 (Pilgrim) on Jan 13, 2019 at 01:48 UTC | |
by LanX (Saint) on Jan 13, 2019 at 02:04 UTC |