in reply to using modules already 'used' (part 2)

Heh, interesting play with the modules ;-) -- although, I can't quite grasp the purpose for such a 'wrapper'. Anyhow, straight onto the question..

Thou art pleas:

did I just get lucky? Am I doing this the most efficient way, or should I be returning a reference to the CGI object?!?

Yes, and no. Yes, you are lucky that you have such a wonderful tool at your disposal as Perl :). Your module is built properly. Frankly, I don't see anything peculiar about it. For the second question, I say 'no' because you are already returning reference to the CGI object, don't you? In your new_cgi() method you are simply invoking the cgi constructor (new()) which returns a reference to a blassed 'CGI' hash. You than simply return that same reference to the caller of your constructor. Therefore, indeed you only deal with references here. I see no point optimizing any further in this direction.

UPDATE: removed my statement of 'faith'.. untill I come up with a new one :)

Replies are listed 'Best First'.
Re: Re: using modules already 'used' (part 2)
by cLive ;-) (Prior) on May 11, 2002 at 16:51 UTC

    I can't quite grasp the purpose for such a 'wrapper'

    I was using CGI in several modules used by several scripts. The two main issues were:

    • POST data only got slurped into the first creation of a CGI object
    • changes to a param() value didn't change that param() in a different namespace

    Because these modules developed organically, there was no clear structure. I didn't want to have to do a lot of re-writing to solve the issues, so creating one shared object quickly solved the problem and (hopefully) future problems.

    cLive ;-)

    --
    seek(JOB,$$LA,0);