# Cruel module author doesn't allow exporting these! my $foo = \%some::very::long::named::module::foo; my $drawSomethingPretty = \&some::very::long::named::module::drawSomethingPretty; foreach my $key ( keys %{ $foo } ) { # It doesn't look like you need $val out here, so why not # just stick in the inner block? if ( testconditions($key) ) { my $val = $foo->{$key}; $drawSomethingPretty->($val); } }