in reply to Re: Idomatic Handling of Subroutine Error
in thread Idomatic Handling of Subroutine Error
Perhaps (looking at your suggestion and making this up as I go...)
Well and good. But what if the problem arises from the logic of my task and not from an eval-able error. Bad data for example.sub my_sub { # do stuff eval { potential icky bit }; if ($@) { return 0; } else { return $something_useful; } } # MAIN unless ( $result = my_sub() ) { # use $@ to figure out what to do }
I'm willing to hid any ugliness in the sub. But how do I best set a retreavable value of my own chosing to flag the problem and still allow succinct, clean code where the sub is called:
unless ( $result = my_sub() ) { # handle error condition based on error var }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Idomatic Handling of Subroutine Error
by dragonchild (Archbishop) on Sep 18, 2001 at 23:35 UTC | |
by dvergin (Monsignor) on Sep 18, 2001 at 23:53 UTC | |
by dragonchild (Archbishop) on Sep 19, 2001 at 00:24 UTC | |
by dvergin (Monsignor) on Sep 19, 2001 at 01:24 UTC |