Skip to content

Instantly share code, notes, and snippets.

Created February 10, 2012 02:07
Show Gist options
  • Save anonymous/1785505 to your computer and use it in GitHub Desktop.
Save anonymous/1785505 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub modhash(&\%) {
my ($sub,$h) = @_;
foreach my $k (keys %$h) {
my $v = delete $h->{$k};
($k,$v) = $sub->($k,$v);
$h->{$k} = $v;
}
}
my %h = (foo => 'oof', bar => 'rab');
modhash { (uc($_[0]), uc(reverse($_[1]))) } %h;
print Dumper(\%h);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment