in reply to Perl OO: switch package context.

I couldn't resist the urge, and wrote Package::Relative. While it makes it's way towards the CPAN, you can download it here.

Here's how it's used:

use Package::Relative; my $object = (PKG . "Class")->new; # your example my $object = (PKG . "..::Class")->new; # more interesting
-nuffin
zz zZ Z Z #!perl

Replies are listed 'Best First'.
Re^2: Perl OO: switch package context.
by samtregar (Abbot) on May 15, 2005 at 20:30 UTC
    Why the heck did you use overload instead of just exporting PKG():

       PKG("..::Class")->new;

    -sam

      I dunno... It's not like I'm going to use this code anyway...

      I thought that __PACKAGE__ like semantics could be cool ;-)

      -nuffin
      zz zZ Z Z #!perl
Re^2: Perl OO: switch package context.
by gaal (Parson) on May 15, 2005 at 17:16 UTC
    This is quite sick. :-)