> Sorry, I wasn't clear. Let me rephrase. The 'try' helps me determine that
> the following block is going to be subject to exception handlers which will
> immediately follow as siblings of the block. Somewhat as I would look at
> an if...elsif...else construct, it helps me put the block in context as I'm
> reading it and also look ahead fo those handlers. I prefer this to
> discovering a handler as I'm reading and then looking for the enclosing
> block, or coming across an undecorated block and scanning to see if this is
> because it has embedded handlers or is to create a closure, or to use a
> redo, or...
like
eval { SomethingThatDies()};
if $@{
$@ =~ /case1/ and DealWithCase1 and return;
$@ =~ /case2/ and DealWithCase2 and return;
$@ =~ /case3/ and DealWithCase3 and return;
die "Unhandled case $@";
LABEL:
};
$@ gets reset at the next eval. I assume these things
nest appropriately, and $@ starts as null inside an eval
and evalling something inside there that dies does not
affect external ones. Testing....
perl -le 'eval{eval{die "i"};print $@};print "now:$@\nok"'
yup.
- Re: assign to magic name-of-function variable instead of &q... Damian Conway
- Re: assign to magic name-of-function variable instead ... Edward Peschko
- Re: assign to magic name-of-function variable instead ... abigail
- Re: assign to magic name-of-function variable inst... John Porter
- Re: assign to magic name-of-function variable inst... Tony Olekshy
- Re: assign to magic name-of-function variable inst... John Porter
- Re: assign to magic name-of-function variable inst... Peter Scott
- Re: assign to magic name-of-function variable inst... John Porter
- Re: assign to magic name-of-function variable inst... Peter Scott
- Re: assign to magic name-of-function variable inst... David L. Nicol
- Re: assign to magic name-of-function variable inst... John Porter
- Re: assign to magic name-of-function variable inst... Peter Scott
- Re: assign to magic name-of-function variable inst... David L. Nicol
- Re: assign to magic name-of-function variable inst... Nicholas Clark
- POST blocks (like END, but in a sub or sub-like sc... David L. Nicol
- Re: POST blocks (like END, but in a sub or sub-lik... Nicholas Clark
- Re: POST blocks (like END, but in a sub or sub-lik... David L. Nicol
- Re: POST blocks (like END, but in a sub or sub-lik... Nicholas Clark
- Re: POST blocks (like END, but in a sub or sub-lik... Bart Lateur
- Re: POST blocks (like END, but in a sub or sub-lik... John Porter
