Carp reference

Perl has a Carp module, that prints error messages from the context of the caller. This page gives an overview of the available functions in the module.

routine output stacktrace exported
carp warn no2 yes
croak die no2 yes
confess die yes yes
cluck warn yes no
longmess return yes3 no
shortmess return no no
  1. Or find the source file of Carp using
    perl -MCarp -e 'print $INC{""}."\n"'
  2. Except if Carp can not determine the caller, for example because all packages are in @CARP_NOT or $Carp::Internal, or $Carp::CarpLevel is set too high. Or if $Carp::Verbose is set, or the symbol verbose is imported.
  3. longmess returns a stacktrace, but the topmost stackframe is missing. The function in which you call longmess won't be in the stacktrace. You can call the undocumented Carp::longmess_heavy directly to get the full stack trace.