Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Modules that do Less

by stephen (Priest)
on Jun 12, 2001 at 18:46 UTC ( #87815=note: print w/ replies, xml ) Need Help??


in reply to Modules that do Less

I do agree that modules sometimes grow larger than is healthy for them. There's always the temptation to add that one additional feature-- it'd be cool, and wouldn't hurt anything, one thinks to oneself. Following this path, one can end up with a module so bloated it's difficult to understand. A module should do one thing and do it well.

Even so, I think that CGI doesn't fall into that category. Even if it has some features that you don't use, these functions aren't hurting you because until you use them they're not even compiled. From Lincoln Stein's web site:

Ordinarily CGI.pm autoloads most of its functions on an as-needed basis. This speeds up the loading time by deferring the compilation phase.

In other words, there's rarely any reason to worry about loading CGI.pm. It loads in only the parts that you use.

stephen


Comment on Re: Modules that do Less
Re: Re: Modules that do Less
by AidanLee (Chaplain) on Jun 12, 2001 at 18:50 UTC
    Thanks, I hadn't visited his web site. This was exactly what I was wondering.
Re: Re: Modules that do Less
by dragonchild (Archbishop) on Jun 12, 2001 at 19:13 UTC
    Having not read the code for CGI.pm, I'm wondering how this is done. Is this a Perl feature or do you have to do a huge amount of contortions to get this to happen?
      A bit of both. CGI goes through huge contortions to do its version of autoloading, because Lincoln Stein is a very clever man who wanted to do things his way. However, using the SelfLoader is pretty simple; you put your functions after a '__DATA__' token and say 'use SelfLoader' at the top. The AutoLoader module is a bit more complicated, but can offer better results.

      stephen

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-10-23 11:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls