exists( deref( deref( $hashRef, "key1" ), "key2" ) ) #### $state = 1; sub retrieve_a_value { # a subroutine that just... does some things # and one of those things involves a state change: $success = Resource::External::retrieve(); $state = 2 if $success; return $success; } sub mess_it_all_up { if( $state == 1 && retrieve_a_value) { $_[0] = 1; } else { return $_[0]; } } if ( mess_it_all_up($hashRef->{key1}->{key2}) ) { ... } else { die "Whoah. I couldn't mess it all up at this point even though I should be able to."; }