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); } }