in reply to Where is the @ISA array?

@__PACKAGE__::ISA means @ISA in the package "__PACKAGE__", not the current package.

use strict; use warnings; use base 'CGI'; print "@main::ISA\n"; # CGI our @ISA; print "@ISA\n"; # CGI my @ourISA = do { no strict 'refs'; @{__PACKAGE__ . '::ISA'} }; print "@ourISA\n"; # CGI

I wouldn't use base. It's even been obsoleted with parent in newer versions of Perl.

Replies are listed 'Best First'.
Re^2: Where is the @ISA array?
by metaperl (Curate) on Jan 21, 2009 at 15:37 UTC
    @__PACKAGE__::ISA means @ISA in the package "__PACKAGE__", not the current package.
    oh, so only with __PACKAGE__-> do I get the current package placed there?

      No, my post shows it being used elsewhere. And here's another:

      $ perl -le'print __PACKAGE__' main

      You wouldn't expect @time::ISA to mean @1232553153::ISA. Same goes for __PACKAGE__. It's a built-in function like time.

      $ perl -le'print CORE::__PACKAGE__' main

      Update: I can override it

      $ perl -wle'BEGIN { *CORE::GLOBAL::__PACKAGE__ = sub () { "abc" }; } p +rint __PACKAGE__' abc

      but I can't call prototype on it

      $ perl -wle'print prototype "CORE::__PACKAGE__"' Can't find an opnumber for "__PACKAGE__" at -e line 1.

      so it's not quite the same as other built-ins. That's probably the only difference.

Re^2: Where is the @ISA array?
by Anonymous Monk on Jan 22, 2009 at 00:01 UTC
    Gosh. I didn't know about parent. What was wrong with base?

      It handles load failures badly.

        So we should just take your word for that? Can you give an example? I mean ... I have never had problems with this like you describe. Perhaps you are not using it properly?