in reply to Imported symbol names

There's a few ways, depending on how much syntactic sugar you want to have.
  1. If you have CGI::MyChild and you can have your users actually do
    use CGI::MyChild qw(:form);
    then you can write your own import() function that will see what is actually being imported. (Look at the source for Exporter to get a feel of what to do.) You can then intercept the importation and have the link to your function be there instead.
  2. If you want to be really slick, you can allow your users to do
    use CGI qw( :form ); use CGI::MessWithForms;
    And, in your import() function, you can see what functions are in %::main and mess with them. Alternately, you could overload the functions in the CGI namespace, but you need to take care with that.

Personally, I'd recommend subclassing CGI and require that everyone create an instance of your class. *shrugs* But, that's just me.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^2: Imported symbol names
by shemp (Deacon) on Jul 08, 2004 at 18:05 UTC
    Any possibility that i could do:
    package CGI::MyChild; use base qw(CGI); use CGI qw(:form);
    and import directly, so the programs using it dont have to add the qw(:form)

    I am a bit over my head on this, havent played symbols games like this very much :)
      You're confusing yourself. How are you going to allow your users to use this? Will they use the OO interface, the procedural interface, or will you allow them to use both? The easiest thing on you is to allow one or the other. The OO interface is easiest and the procedural isn't too difficult, once you see it done once. Doing them both is going to be more trouble than it's worth, IMHO.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

        I think you're correct i was confusing myself. Im really only going for the OO interface, i just dont see the point of the function oriented interface, eventually someone will have symbol clashes