Chandrasekaran Suresh wrote:

> Hello, 
> 
>  I am calling a perl module from my one perl script.
> Inside the module I am working with some database. IF
> found error during the execution in the module in need
> to exit from the subroutine and continues the
> process.. 
> 
> How to handle this situation

sub my_sub {

...

if ($error_occurred) {
        return 0;       # 0 or undef returned on failure
                        # you could also store a string
                        # in a global and add a method
                        # to retrieve the error string.
# you could also return the string as part of your return
# by returning an array:
        return (0, "Fubar error occurred");
# or you could number each possible error and return if
(probably as a negative number):
        return -12;     # where error (-)12 is "Fubar error occurred"

}

...

return 1;       # 1 or true returned on good execution

}


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to