#!perl use strict; use warnings; BEGIN { package Hash::Adjust; use Exporter::Shiny 'ha'; sub _generate_ha { my ( $me, $name, undef, $opt ) = ( shift, @_ ); my ( $aref, $bref ) = do { no strict 'refs'; my $caller = $opt->{into}; ( \${"$caller\::a"}, \${"$caller\::b"} ); }; return sub (&\%) { my ( $code, $hashref ) = ( @_ ); @_ = (); my %tmp; while ( ( $$aref, $$bref ) = each %$hashref ) { &$code; $tmp{$$aref} = $$bref if defined $$aref; } %$hashref = %tmp; }; } }; use Hash::Adjust 'ha'; use Data::Dumper; my %hash = ( FOO => 42, BAR => 666 ); ha { $a =~ s/O/o/g; ++$b; } %hash; print Dumper \%hash;