sub foo { my $hashref = shift; while ( my ( $key, $value ) = each %$hashref ) { return if sometest( $key ); frobnicate( $key, $value ); } }