Is it possible for a Perl subroutine to force its caller to return?

Posted by Kinopiko on Stack Overflow See other posts from Stack Overflow or by Kinopiko
Published on 2010-05-20T06:41:15Z Indexed on 2010/05/21 0:40 UTC
Read the original article Hit count: 361

Filed under:

If I have Perl module like

 package X;

and an object like

 my $x = X->new ();

Inside X.pm, I write an error handler for $x called handle_error, and I call it

 sub check_size
 {
     if ($x->{size} > 1000) {
         $x->handle_error ();
         return;
     }
 }

Is there any way to make handle_error force the return from its caller routine? In other words, in this example, can I make handle_error do return in check_size without actually writing return there?

© Stack Overflow or respective owner

Related posts about perl