http://qs321.pair.com?node_id=130421


in reply to Re: Re: __PACKAGE__ interpolated before inheritence
in thread __PACKAGE__ interpolated before inheritence

__PACKAGE__ is turned into, at compile time, the current package when it is compiled. (That is, the one established by package statements.)

Replies are listed 'Best First'.
Re4: __PACKAGE__ interpolated before inheritence
by blakem (Monsignor) on Dec 09, 2001 at 01:44 UTC
    To see this in action:
    % perl -MO=Deparse -e 'use constant Y => "foo"; $x="bar"; return __PAC +KAGE__, $x, Y' sub Y () { package constant; $scalar; } $x = 'bar'; return 'main', $x, 'foo'; # <=== inlined values at compile time...
    Notice that __PACKAGE__ and the constant Y got inlined at compile time, whereas $x did not.

    -Blake