in reply to Pass by reference: is it good form to grope @_?
When I need a subroutine to modify one (or more) scalar variables I usually use a 3rd method: I send the value back in the return.
It seems that you want the subroutine to return a status. But even then couldn't you use undef as a failure signal?
unless( defined( $variable= foo( $variable))) die "horrible death: $sn +afu::ERROR"; package snafu; my $ERROR; sub foo { # interesting things happen if ( $things_worked ) { return $baz; else { $ERROR= "horrible death"; return undef; }
I actually very rarely modify $_[0] and al. I don't like side effects and I prefer to see clearly which variables are modified by a function.
|
|---|