unless( defined( $variable= foo( $variable))) die "horrible death: $snafu::ERROR"; package snafu; my $ERROR; sub foo { # interesting things happen if ( $things_worked ) { return $baz; else { $ERROR= "horrible death"; return undef; }