sub unspace_keys { my $hash = shift; if (ref($hash) eq 'HASH') { my $out = {}; for my $k (keys %$hash) { (my $k1 = $k) =~ s/\s+//g; $out->{$k1} = unspace_keys($hash->{$k}); } return $out; } else { return $hash; } } my $new = unspace_keys( \%global ); print Dumper \%global; print Dumper $new;
In reply to Re: removing the spaces from keys of a complex hash
by pc88mxer
in thread removing the spaces from keys of a complex hash
by gwhite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |