JupiterHost.Net am Montag, 27. November 2006 21:37: > > What about doing this? > > > > return if do_one_then_two($whatever); > > ... > > sub do_one_then_two { > > my $what = $_[0]; > > if ($what) { > > one(); > > two(); > > return 1; > > } > > return 0; > > } > > Thanks, I'm not looking for how to handle a condition necessarily.
Dear JupiterHost.Net > I want to be able to: > > log_error_and_return($error, @return) if $whatever; That's what you want? And it should return @return? > instead of > > if($whatever) { > log_error(); > carp $error; > return @return; > } > > basically I want to override return to log and carp first, every time > its called. Ok, another try (I would not use it myself): sub my_return { my ($error, $return_data)[EMAIL PROTECTED]; # do what boss wishes today return $return_data; } # unconditional usage: # return my_return($error, $return_data); # conditional usage: # return my_return($error, $return_data) if $whatever; foo() unless returned_above(); ======== I think you have to explicitly use the return. Otherwise, Tom Phoenix's notes apply. It's a really good thing to see 'return' at exactly the place where the code does (or can) return to the caller. ======== I'm not sure if glueing together such different things as handling error messages and returning application data is a good thing... Do you now of the possibility to override $SIG{__WARN__}? This would allow to keep recommended and usual coding style. Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>