Now use that module with the following one-liners:package Foo; use Carp qw(croak); use base qw(Exporter); our @EXPORT_OK = qw(gonna_croak gonna_die); sub gonna_die { die "ya got me!" } sub gonna_croak { croak "ya got me!" } 1;
$ perl -MFoo=gonna_die -le gonna_die ya got me! at Foo.pm line 7. $ perl -MFoo=gonna_croak -le gonna_croak ya got me! at -e line 1die reports the error from the actual line it was executed on, which might be many packages deep. croak, on the other hand, reports the error from the perpestive of the caller, which is usually more useful to the end user. The end user usually cares more about which line of their code caused the problem, not which line in the module it affected.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: Advice for moving forward with modules
by jeffa
in thread Advice for moving forward with modules
by newrisedesigns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |