my $output_handle = myfunction(); if ( $output_handle ) { print $output_handle $whatever; } else { # deal with null-handle error }