in reply to Hash problem (possible recursion)
foreach my $dir (sort { length($b) <=> length($a) } keys %hash) { next unless $dir =~ m{^(.*)/[^/]*$}; my $parent = $1; next unless exists $hash{$parent}; $hash{$parent}{dir} += $hash{$dir}{dir}; }
The sort is essential in propagating the changes towards the root.
|
|---|