in reply to Jumping trought lot of subroutines
To capture the value returned, you can do this:sub example { my $number = shift; eval { if (2 / $number > 3) { return 1; } }; print "Still here\n"; }
And if you would like to explore a bit further you could look into some CPAN modules that provide exception objects, which help you to communicate the cause of the failure to listeners up the chain.my $value = eval { # Do stuff; return 4; };
I'm fond of Exception::Class, and you might find Exception::Class::TryCatch useful.
And a discussion from perlmonks about Exception::Class - Exception::Class - how to use?
|
|---|