in reply to Re: style for returning errors from subroutines
in thread style for returning errors from subroutines

My gut feeling when I read this was that there was going to be a pretty serious impact on program speed; but assuming my Benchmarking isn't totally silly, there is no significant efficiency loss:
use strict; use Benchmark; timethese(100000, { 'Using Eval' => 'eval { &test or die }; $@ and warn("maths +sux:$@");', 'using or' => '(&test) or warn("maths sux:$@");', }); sub test { #A test which always returns true for(1..100) {($_>0) || return 0} return 1; } boldra@trinity:~/workspace$ ./eval_test.pl Benchmark: timing 100000 iterations of Using Eval, using or... Using Eval: 10 wallclock secs ( 6.46 usr + 0.06 sys = 6.52 CPU) using or: 10 wallclock secs ( 6.28 usr + 0.11 sys = 6.39 CPU)
It does, however, look pretty messy to (IMHO) do this for every subroutine call, and it doesn't allow me to put non-fatal errors in my subroutines.