Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: lighter alternative to CGI.pm

by Ovid (Cardinal)
on Aug 29, 2002 at 19:13 UTC ( #193866=note: print w/replies, xml ) Need Help??


in reply to lighter alternative to CGI.pm

Perhaps you can check out CGI::Simple. It loads and runs much quicker than CGI. tachyon appears to have written a nice alternative that is a drop-in replacement for CGI.pm. You can read a comparison at http://search.cpan.org/src/JFREEMAN/Cgi-Simple-0.04/cgi-simple_vs_cgi-pm.html.

Also, are you using ISAPI, or is IIS relying on the file association to load Perl? If the latter, you may wish to switch to ISAPI for improved performance, but you'll lose taint checking.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: Re: lighter alternative to CGI.pm
by perrin (Chancellor) on Aug 29, 2002 at 19:17 UTC
    Thanks. I don't suppose anyone has ever compared CGI::Simple to CGI_Lite?

    The server is using the ISAPI Perl DLL. Taint-checking? I wish. This is someone else's legacy code, and it doesn't even use strict. I'm hacking out my own little island of clean code in the middle of it, with hopes of eventually expanding to conquer the rest.

      I'm not aware of any comparisons. I like CGI::Simple because it's a drop-in replacement. Converting your code will be ridiculously simple. Since CGI_Lite does not share the same interface you have a longer conversion time and a greater likelyhood of bugs.

      One feature of CGI_Lite that you have to contend with is the setting of the OS type to determine line endings with file uploads. If someone simply hardcodes the OS in there, you now have non-portable code.

      I just took a look at the CGI_Lite code and spotted a bug. The separator for query strings is defined in the module as an ampersand. It should also support a semi-colon as that's the recommended separator -- though I confess that few use it.

      I also noticed that the CGI_Lite::is_dangerous() method skips the null byte. Oh wait! It's not even a method, it's a function, so you can't subclass it. If you need to subclass it (though it sounds like you don't), you'd have to reimplement all of the functions in there that don't pass $self as the first argument.

      All in all, CGI_Lite looks like a nice module, but I see some issues with it that could stand some fixing.

      Cheers,
      Ovid

      Update: I just noticed that the is_dangerous function also explicitly returns a zero for false. While I think it's clear that this is to be called in a scalar or boolean contect, if someone were to accidentally assign the results to an array, the array would automatically evaluate as true. Boolean responses should have a bare return for false, but now I think I'm just getting picky. It still appears to be a very useful module.

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

        I just tested it, and for the very minor use that I'm putting it to CGI::Simple is actually slower than CGI.pm. I'm a little bit boggled by this result, but I guess it's just a matter of the particular functions I'm using. CGI_Lite, on the other hand, gives about a 60% speed increase in the overall execution time of the script.
Re: Re: lighter alternative to CGI.pm
by archen (Pilgrim) on Aug 30, 2002 at 00:37 UTC
    Thanks for the info on CGI::Simple! As someone who never uses the HTML side of CGI, this is perfect for a lot of projects I'm working on.
    Okay, that's offtopic enough =P

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-04-13 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?