Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Carp croak not working when used in an imported function

by mreece (Friar)
on Sep 29, 2006 at 22:49 UTC ( [id://575616]=note: print w/replies, xml ) Need Help??


in reply to Carp croak not working when used in an imported function

try this?
sub errmsg { local $Carp::CarpLevel = 1; Carp::croak "$_[0]"; }

update: i understand this is a rather contentious 'feature'! some suggest +=1 instead, or consider Carp::Clan..
again: +=1 doesn't work as i expected on a local, use local $Carp::CarpLevel = $Carp::CarpLevel + 1; as shenme suggested below!

Replies are listed 'Best First'.
Re^2: Carp croak not working when used in an imported function
by shenme (Priest) on Sep 29, 2006 at 23:04 UTC
    Quick, before tilly notices, change that to
    local $Carp::CarpLevel = $Carp::CarpLevel + 1;
Re^2: Carp croak not working when used in an imported function
by fmerges (Chaplain) on Sep 29, 2006 at 23:25 UTC

    Hi,

    Why quoting the parameter to croak? "$_[0]" -> $_[0]

    I don't see the problem:

    cucu.pm
    package cucu; use strict; use Carp (); sub error { Carp::croak @_; } 1;
    t.pl
    use strict; use cucu; ty(); sub ty { cucu::error('blabla'); }

    Regards,

    fmerges at irc.freenode.net
Re^2: Carp croak not working when used in an imported function
by Anonymous Monk on Sep 29, 2006 at 23:12 UTC
    That did it! Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575616]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found