sub recIterate{ my $ref = shift; my $funcRef = shift; #mutation function reference if(ref($ref) =~ /HASH/){ my %copy = %$ref; foreach my $item (keys %copy){ $copy{$item} = recIterate($copy{$item}, $funcRef); } %$ref = %copy; }elsif(ref($ref) =~ /ARRAY/){ my @copy; foreach my $item (@copy){ push(@copy, recIterate($item, $funcRef); } @$ref = @copy; }elsif(ref($ref) eq ''){ #i think this is how scalars #look to ref, but you might #want to look it up $$ref = &$funcRef($$ref); } } #### #you will need to define your own mutator function sub someFunc{ #removes tabs my $old = shift; my $new = $old; $new =~ s/\t//g; return $new; } %nDimHash; #this might be a HoAoHoAoAoAoS or whatever; %nDimHash = recIterate(\%recIterate, \&someFunc); ####