Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl OO: switch package context.

by nothingmuch (Priest)
on May 15, 2005 at 06:37 UTC ( [id://457170] : note . print w/replies, xml ) Need Help??


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. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://457170]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-02-05 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found