sub my_die { open(my $fh, ">>", $dieFile); print $fh @_; exit(2); # or die("\n"); # or die(@_); } my $value = somecommand or my_die "$!\n";