Carp -- shortmess and longmess

Discussion in 'Perl Misc' started by Haakon Riiser, Jul 26, 2004.

  1. perldoc Carp says:

    carp - warn of errors (from perspective of caller)
    cluck - warn of errors with stack backtrace
    (not exported by default)
    croak - die of errors (from perspective of caller)
    confess - die of errors with stack backtrace
    shortmess - return the message that carp and croak produce
    longmess - return the message that cluck and confess produce

    but this is not how it appears to work. I created a test program
    based on the examples in the manual:

    --- begin carp.pl ---
    use Carp qw(croak cluck);

    sub foo {
    cluck "This is how we got here!";
    print Carp::shortmess("This will have caller's details added");
    print Carp::longmess("This will have stack backtrace added");
    croak "We're outta here!";
    }

    sub bar {
    foo();
    }

    bar();
    --- end carp.pl ---

    When I run this program, I get the following output:

    This is how we got here! at carp.pl line 4
    main::foo() called at carp.pl line 11
    main::bar() called at carp.pl line 14
    This will have caller's details added at carp.pl line 5
    main::foo() called at carp.pl line 11
    main::bar() called at carp.pl line 14
    This will have stack backtrace added at carp.pl line 11
    main::bar() called at carp.pl line 14
    We're outta here! at carp.pl line 7
    main::foo() called at carp.pl line 11
    main::bar() called at carp.pl line 14

    The message from cluck seems to be OK -- it prints the backtrace,
    as it should. The next two, shortmess and longmess, appear
    to do the opposite of what they should. shortmess prints the
    longest message, backtrace and everything, while longmess only
    prints the bottom of the stack. It should've been the other
    way around, right? croak also prints the full backtrace, which,
    if I understand the manual correctly, is incorrect.

    In summary: carp, cluck, croak and confess all print the full
    backtrace (same as shortmess), and the longmess message is
    never used.

    Verified on the following systems:

    Custom built Perl 5.8.4 (-Duse64bitint -des), Caro 1.02
    Custom built Perl 5.8.5 (-Duse64bitint -des), Carp 1.03
    Slackware 10's Perl 5.8.4, Carp 1.02
    Red Hat Enterprise Linux WS release 3's Perl 5.8.4, Carp 1.02

    Is this a known bug, or should I report it with perlbug?

    --
    Haakon
     
    Haakon Riiser, Jul 26, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Louis Erickson
    Replies:
    2
    Views:
    221
    James Willmore
    Sep 3, 2003
  2. Jo Oberman
    Replies:
    5
    Views:
    227
    Ilya Zakharevich
    Sep 14, 2003
  3. Gunnar Hjalmarsson

    CGI::Carp and "useless quotes"

    Gunnar Hjalmarsson, Apr 4, 2004, in forum: Perl Misc
    Replies:
    12
    Views:
    215
    Gunnar Hjalmarsson
    Apr 16, 2004
  4. joe
    Replies:
    2
    Views:
    374
    Peter J. Acklam
    Apr 10, 2004
  5. George Mpouras

    CGI::Carp and File::Temp

    George Mpouras, Mar 26, 2014, in forum: Perl Misc
    Replies:
    7
    Views:
    177
    Rainer Weikusat
    Mar 27, 2014
Loading...

Share This Page