[Classiccity-pm] How big is CGI.pm?

Mark Hazen markh at markh.com
Fri Sep 19 22:46:11 CDT 2003


To answer the questions....

No, I didn't use CGI::Lite, or anything of the sort. Despite a common
belief about CGI and mod_perl, you don't *need* anything. You can write
headers and parse POST or GET data yourself quite easily, and URL encoding
is simple to decode as well, via something like:

   $url_decoded =~ s/%([\dabcdef]{2})/chr(hex $1)/egi;

...and so forth. Environment variables from teh web server are always 
available in the the %ENV hash.

Sure, CGI.pm makes life very, very easy, but the whole CGI spec is made up
of simple pieces that, if you ony need one tiny bit of the functionality, 
you can likely just code inline. Yes, I usually use CGI.pm myself, too.

As for my sampling rate? This was a run-once on the command line program,
not a CGI, just to give an idea of how much space CGI.pm takes, when
compiled. My code, quite literally, was:

   #!/usr/bin/perl
   use CGI;
   sleep 100;

...and the stats were picked up via 'top'.  the 'nocgi' version simply
didn't have a 'use CGI' statement. It's as basic as it gets.

As for shared memory, unless you're loading in CGI.pm as a PerlRequire
module under Apache (not a great idea unless everything you write uses
CGI.pm), it won't get shared between children under mod_perl.... so you're
pretty much always going to be stuck with most of that memory overhead.

Really, the point here was just to illuminate one of the reasons some 
people don't like CGI.pm, that being its monolithic nature. Note, I say 
some people... I'm not fanatical either way (though I prefer efficency 
where possible, of course).

Cheers,

-mh.
----
   . _+m"m+_"+_    Mark Hazen
 d' Jp     qh qh    
Jp  O       O  O    
Yb  Yb     dY dY 
 O   "Y5m2Y"  "  even the mightiest wave starts out as a ripple.
  "Y_            why make waves when it's easier to nurture ripples?





More information about the Classiccity-pm mailing list