sub my_sub{ my $handle = shift; if (handle_not_valid($handle)){ $handle = new_handle(); } ... }