On Tue, Jul 10, 2001 at 09:46:27PM -0400, Morbus Iff wrote:
> I think the only other one I had regarding the param() sort of interface
> was the fact that I had to assign the value of a param to an interim value
> (is that right?). So instead of:
> 
>    print "The color is $form->{foo}";        # the way i want
>    print "The color is param('foo')";        # the way i'd want
> 
> I'd have to do:
> 
>    my $color = param('foo');
>    print "The color is $color";
> 
> Is that accurate?

Not entirely:

    print "The color is ", param('foo');
    print "The color is @{[ param('foo') ]};

Better yet:

    use Template;
    use CGI;
    my $cgi = CGI->new;
    my $template = Template->new(PRE_DEFINE => { cgi => $cgi });
    $template->process(\"The color is [% cgi.param('foo') %]");

but that's my personal preference for most of my CGI problems, and this is
of course a trivial problem to be applying a templating engine.
   

> So there's no additional overhead to using a routine from CGI.pm? I work
> for an ISP where a spike on MRTG spells instant "remove that script!
> remooovee thattt scripppppt!!".

I don't get this, what does unused code in a Perl script have to do with
network traffic?


> I'm not trying to be sarcastic - what happens to the other 180k of code
> that I don't use? Is it ever loaded into Perl? It must take up some
> something, right? I had read previously that CGI.pm is super smart in that
> aspect, and doesn't load junk that it doesn't need, but doesn't the
> dormant code cause some effect? What if this script is being hit a
> hundreds of thousands of times a week (mod_perl is not an option)?

I really can't tell you how bloated and/or inefficient CGI.pm is, if it is,
because I haven't done any testing, nor seen any done.  However, hundreds of
thousands of hits in a week can be handled pretty easily by even a bloated
CGI script without affecting the server.  If you meant to quote a larger
figure, indicating a heavily loaded site, then you really shouldn't be using
plain old CGI scripts.  Your resources will get hit hardest by the constant
forking and execution of perl, not the code in your script.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to