Not quite but thank you for the reply. I have created the following sub:
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 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"
. I tried to add:
$files_href->{data} = ();
$files_href->{total} = ();
But it also does not work. it wants a real hash (because we do dereferencing with %{$final_href->{data}).
Any ideas how to solve it?