Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Creating packages on the fly

by Jouke (Curate)
on Jun 06, 2006 at 09:01 UTC ( #553768=note: print w/replies, xml ) Need Help??

in reply to Re: Creating packages on the fly
in thread Creating packages on the fly

I may be overlooking something, but how does that create packages that the code doesn't know about yet on the fly?

Maybe I need to be clearer:

Wx provides Wx::Window. Let's say that I'm going to use the namespace Jouke:: and my Wx::Window subclass would become Jouke::Wx::Window. I don't want to have a predefined list of classes I want to subclass under Jouke::, but whenever the main program calls Jouke::Wx::Window->new() it should be able to identify if Wx::Window->new can be called, and if so, subclass it as Jouke::Wx::Window, and add functionality to it.

The only part I'm having trouble with, is having a mechanism that catches every call to Jouke::Foo->whatever_method() without having to define Jouke::Foo in advance.

Jouke Visser
Using Perl to enable the disabled: pVoice

Replies are listed 'Best First'.
Re^3: Creating packages on the fly
by vkon (Curate) on Jun 06, 2006 at 09:28 UTC
    you're right, Jouke::Foo->whatever_method() isn't covered in my example.

    Here is one that do:

    sub UNIVERSAL::AUTOLOAD { print STDERR "[[@_]]"; } package main; Jouke::Foo->whatever_method();
    D:\TESTS\tperl>perl -w [[Jouke::Foo]]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://553768]
[thezip]: How goes it, Corion?
[Corion]: thezip: Quite good, after a one week vacation in the sun ;)
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.
[Corion]: thezip: The Canary Islands - they have a constant climate

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-02-23 17:01 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (349 votes). Check out past polls.