http://qs1969.pair.com?node_id=554088

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Carp can't deal with UNIVERSAL::AUTOLOAD
by ikegami (Patriarch) 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.

    -derby
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.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊