Well, it depends on your criteria.
If your criteria is execution time, yes, your procedure will execute faster
than loading CGI.pm (perhaps some microseconds or nanoseconds).
If your criteria is development time, no, it's faster to reuse CGI.pm:
+ it's working: you'll take time to test your procedure. Perhaps, you'll
have to deal with some not thought situation.
+ you can extend CGI.pm: see CGI::Application, as an example.
+ if you find an error in CGI.pm, a lot of people will benefit.
+ consider also that in software cycle life, maintenance is where you spend
most time.
If your criteria is learning, well, maybe time should not be a strong concern.
--
Vinicius Jose Latorre
CPqD - Telecom & IT Solutions
e-mail : [EMAIL PROTECTED]
voice : +55 19 3705 6678
fax : +55 19 3705 6786
--- perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
G.P.Gaudreault <[EMAIL PROTECTED]> wrote:
> All,
>
> Which is faster, using the CGI.pm param function to get form input, or =
> parsing out the hash within my script? I've got a script that currently =
> uses a lot of system resources, and I'm looking for ways to optimize it.
>
> I have the following subroutine in my script:
>
> sub getform {
> $buffer = "";
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs=split(/&/,$buffer);
> foreach $pair (@pairs) {
> @a = split(/=/,$pair);
> $name=$a[0];
> $value=$a[1];
> $value =~ s/\+/ /g;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/~!/ ~!/g;
> $value =~ s/[\r\n]//g;
> push (@data,$name);
> push (@data,$value);
> }
> %form=@data;
> %form;
> }
>
> Is it faster to run this, or use CGI.pm and call param()?
>
> -GPG
>
>
>
> Visit Zanpo, Virtual City
> http://www.zanpo.com