Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Carp can't deal with UNIVERSAL::AUTOLOAD

by jesuashok (Curate)
on Jun 07, 2006 at 16:43 UTC ( #554088=perlquestion: print w/replies, xml ) Need Help??
jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

dear monks,

#!/usr/bin/perl -w use Carp; sub UNIVERSAL::AUTOLOAD { carp "foo"; } bar(); Error :- <code> foo at line 5 UNIVERSAL::AUTOLOAD() called at line 8
Could any one explaine me why can't Carp deal with UNIVERSAL::AUTOLOAD

"Keep pouring your ideas"

Replies are listed 'Best First'.
Re: Carp can't deal with UNIVERSAL::AUTOLOAD
by ikegami (Pope) on Jun 07, 2006 at 17:29 UTC

    Your problem has nothing to do with either UNIVERSAL or AUTOLOAD. You're seeing that behaviour because your AUTOLOAD was built in package main. Examine the following:

    sub Test1::print_context { print(__PACKAGE__, "\n"); } { package Test2; sub print_context { print(__PACKAGE__, "\n"); } } Test1::print_context(); # main Test2::print_context(); # Test2

    Fixed code:

    #!/usr/bin/perl -w { package UNIVERSAL; use Carp; sub AUTOLOAD { carp "foo"; } } bar();
Re: Carp can't deal with UNIVERSAL::AUTOLOAD
by derby (Abbot) on Jun 07, 2006 at 16:50 UTC

    Maybe because UNIVERSAL is the base class for all classes and bar is not a method but a subroutine. Maybe ... your code works fine for my version of perl (5.8.2) but I do get a deprecation warning -- Use of inherited AUTOLOAD for non-method main::bar() is deprecated.

Re: Carp can't deal with UNIVERSAL::AUTOLOAD
by perrin (Chancellor) on Jun 07, 2006 at 17:14 UTC
    UNIVERSAL::AUTOLOAD? You're really going to make life hard for yourself if you start messing with that. All kinds of strange things may happen.
Re: Carp can't deal with UNIVERSAL::AUTOLOAD
by diotalevi (Canon) on Jun 07, 2006 at 17:36 UTC

    Ok, so it doesn't examine $UNIVERSAL::AUTOLOAD. And? Patch Carp from bleadperl and send it in to p5p. Read perlhack for details.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://554088]
Approved by Joost
[Corion]: marto: Live video or are they recording and storing inspection videos? If it's for archival, who is rewatching that stuff? ;)
[Discipulus]: imperial infiltration
[marto]: Corion none of it is live, all recordings, in the first instance they need to transfer video from dead/dying media (DVDR, VHS, Laserdisc and so on)
[marto]: Discipulus, yeah pretty much robots going around parts of the plant humans can't

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-07-28 09:36 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (425 votes). Check out past polls.