http://www.perlmonks.org?node_id=996097

neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting this error message that is to vague for me to follow.
Goto undefined subroutine &Carp::longmess_real at /usr/share/perl5/Car +p.pm line 35, <FH> line 1.
My code base is large. I'll list the beginning parts since I think that might be the problem. First
#!/usr/bin/perl BEGIN { push @INC, "/home/neil/perl5/lib/perl5" } use strict; use warnings; use local::lib; use Evolvethinking::Mymodule; use POSIX 'strftime';
And the module.
package Mymodule; { use Mouse; use Mouse::Util::TypeConstraints; use Socket; ... subtype 'my_timestamp', => as 'Str', => where { m/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/ }, => message { 'Not a valid timestamp. Expect: yyyy-mm-d +d hh:mm' }; has 'timestamp' => ( is => 'ro', isa => 'my_timestamp' );

Update

Carp::Any shows that my typing is working properly by returning an error. However, I wonder why the error was so vague.
Attribute (insert_class) does not pass the type constraint because: No +t a valid class at /home/neil/perl5/lib/perl5/x86_64-linux-thread-mul +ti/Mouse/Util.pm line 383, <FH> line 1. Mouse::Util::throw_error('Mouse::Meta::Attribute=HASH(0x161869 +8)', 'Attribute (insert_class) does not pass the type constraint be.. +.', 'data', '192_168_0_151', 'depth', -1) called at /home/neil/perl5/ +lib/perl5/x86_64-linux-thread-multi/Mouse/Util.pm line 383, <FH> line + 1. Mouse::Util::throw_error('Mouse::Meta::Attribute=HASH(0x161869 +8)', 'Attribute (insert_class) does not pass the type constraint be.. +.', 'data', '192_168_0_151', 'depth', -1) called at ./p1.pl line 35 .... subtype 'my_insert_class', => as 'Str', => where { m/^[a-zA-Z0-9]+$/ }, => message { '$_ is not a valid class' }; has 'insert_class' => ( is => 'rw', isa => 'my_insert_class' );
Also, is there a way to have this typing do something other than exit? I'd really like to to just return none zero.

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Help with vague Carp error message
by tobyink (Canon) on Sep 28, 2012 at 06:28 UTC

    What version of Carp do you have installed? If I recall correctly, Moose needs a fairly recent version but until recently didn't indicate so properly.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

        You might have 1.26 installed somewhere, but I believe Perl is finding and using an older version. The longmess_real and shortmess_real subs were purged a few years ago, in the 1.1x series IIRC.

        Basically the way they were defined/used was that the (long|short)mess_real functions were defined inside Carp/Heavy.pm, and were called from Carp.pm itself. In recent versions Carp/Heavy.pm is not much more than an empty file, and Carp.pm doesn't call (long|short)mess_real at all.

        So what I'm assuming is that Perl is finding an old version of Carp.pm (which calls longmess_real) but a new version of Carp/Heavy.pm (which does not define longmess_real).

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Help with vague Carp error message
by Anonymous Monk on Sep 28, 2012 at 02:25 UTC