LogoopenSUSE Build Service > Projects
Sign Up | Log In

Alternative warn and die for modules

The Carp routines are useful in your own modules because they act like
'die()' or 'warn()', but with a message which is more likely to be useful
to a user of your module. In the case of 'cluck()' and 'confess()', that
context is a summary of every call in the call-stack; 'longmess()' returns
the contents of the error message.

For a shorter message you can use 'carp()' or 'croak()' which report the
error as being from where your module was called. 'shortmess()' returns the
contents of this error message. There is no guarantee that that is where
the error was, but it is a good educated guess.

'Carp' takes care not to clobber the status variables '$!' and '$^E' in the
course of assembling its error messages. This means that a '$SIG{__DIE__}'
or '$SIG{__WARN__}' handler can capture the error information held in those
variables, if it is required to augment the error message, and if the code
calling 'Carp' left useful values there. Of course, 'Carp' can't guarantee
the latter.

You can also alter the way the output and logic of 'Carp' works, by
changing some global variables in the 'Carp' namespace. See the section on

Source Files

Filename Size Changed Actions
Carp-1.33.tar.gz 18.2 KB Download File
perl-Carp.changes 179 Bytes Download File
perl-Carp.spec 3.34 KB Download File

Comments for home:computersalat:devel:perl (0)

Login required, please login or signup in order to comment