in reply to Re: style for returning errors from subroutines
in thread style for returning errors from subroutines
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.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)
|
|---|