[Chicago-talk] fun with Carp
Kent Cowgill
kent at c2group.net
Tue Jul 31 10:21:48 PDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Is this what you're looking for:
$Carp::CarpLevel = 1;
$ perl ctest.pl
attempt failed; quitting at ctest.pl line 17
main::quit_gracefully('attempt failed; quitting') called at
ctest.pl line 5
- -Kent Cowgill
C2 Group, Inc.
kent at c2group.net
http://www.c2group.net
312.804.0160
On Jul 31, 2007, at 11:37 AM, Mike Fragassi wrote:
> use Carp;
>
> attempt_something()
> or quit_gracefully("attempt failed; quitting");
>
> sub attempt_something {
> # Oops, the attempt fails:
> return undef;
> }
>
> sub quit_gracefully {
> my $error_msg = shift;
> # ... do some recovery operations here ...
> # ... and then call quit():
> quit($error_msg);
> }
>
> sub quit {
> my $error_msg = shift;
> # ... do some other stuff here, and then, the coup de grace:
> Carp::croak($error_msg);
> }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iD8DBQFGr2+tRiDfSpIkEfoRApHfAJ0faM/iyAoi6CN10WMe2DCWn4d0kgCfW5iR
DtWFAqnrbZkh0N1dhXXGa4I=
=jQ+J
-----END PGP SIGNATURE-----
More information about the Chicago-talk
mailing list