CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Calling all OO heads, W3.pm needs you.

 



YAPHacker
Deleted

Dec 29, 2000, 10:56 AM

Post #1 of 2 (545 views)
Calling all OO heads, W3.pm needs you. Can't Post

Hey, Perl Hackers. Here's one to chew on:

DAVE CROSS -
> I've seen probably hundreds of CGI param parsing functions over the last
> four years. Of that number I can remember about five that didn't have a
> serious bug in them (generally the multi-valued parameter bug or a subtle
> varient). If reimplementing basic functionality like this is such a good
> idea, then why do so many people get it wrong time and time again?

The more often you do something, the more chances you give yourself to botch
it up I guess.

JEFF PINYAN -
> The few lines of code does the job THIS time. Then you try to use it
> another similar case, but maybe it won't work correctly there. So you
> need to beef it up a bit. With CGI queries, I'd say a handful of people
> know what they're doing, and have actually read documentation on how it
> works. Sure, you could write code that reads a GET query. And one that
> reads a POST query. And then wonder why neither seems to work with a file
> upload. And then try to munge something else up. But CGI.pm knows what
> it's doing -- it's kid-tested, mother-approved.

Sure is. Tried and true. But...

$BILL LUKEBERT -
> In my case, I don't want that humongous module loaded just for parsing and
> I do a couple of special things in my parsing that are not in CGI. Also
> I don't consider my code any more home-grown than Lincoln's code and much
> more specific to my needs. :)

DAVE CROSS -
> ...but surely you must agree that reuseable code is a good idea?

"Laziness, impatience and hubris" 2 out of 3. -Yep. The average perl hacker
would. So what's the solution here?

DAVE CROSS -
> If you've got a better (or faster or lighter
> or more flexible) piece of code for parsing CGI parameters, why not bundle
> it up into a module so that you can reuse it in all of your scripts
> without cut-and-paste.

Ok. Why not... 'Cause you know, just the other day I was thinking, "this
might be fun." So I started writing W3.pm to accomplish exactly those
objectives which you just read above in Dave's suggestion. But I'm a fairly
limited person all by myself. I was hoping that we might all make this a
team effort -- kind of like SETI, MOZILLA, or Apache but on a smaller scale
(after all, that *is* the point.) I'm gonna make the code, and any
accompanying files for W3.pm available at
ftp://tommybutler.com/pub/perl/modules/W3.zip with the hopes that you OO
heads out there like DAMIAN CONWAY and JAPHY PINYAN take a shine to the idea and help me out.

Now W3.pm does some pretty cool stuff. So far it gives you the ability to
use embedded perl in templates you create too. It needs help though, both
in the documentation area, and in the code itself. For example, just as
Dave mentioned, I still haven't given it the power to read multi-part form
data for uploads. See a working version of the code at
http://tommybutler.com/cgi-bin/testW3.cgi/virtual/path/info/right_here?hi=1;foo=my second param&bar=yet+another;tommy=me...&alpaca=a+camel;Larry=a+good guy


- tommy, yetanother.perlhacker@atrixnet.com


AND JUST FOR FUN...

DAVE CROSS -
> I don't believe that modules are a cure-all...

Sure they are! My modules will take 10 pounds off your flabby tummy in less
than 30 days or your money back! And they're FREE! They prevent male
pattern baldness, take the dog on walks, keep you cool in summer, warm in
winter -- They cure cancer, and remove warts! They will even make you
irresistable to women ( or men... depending on which way you go )! But
wait, there's more!

When you 'use' one of my modules in the next 30 minutes, we'll throw in a
free set of ginsu knives! You heard right! A 50 dollar value for FREE when
you do{} it NOW!



rGeoffrey
User / Moderator

Dec 29, 2000, 9:29 PM

Post #2 of 2 (540 views)
Re: Calling all OO heads, W3.pm needs you. [In reply to] Can't Post

I have a module CGI::Thin that will get the form data for POST, GET, and encoded forms.

It does only one thing, return a hash of the form data. That is it. It will not help you write HTML or do any of the other neat things that CGI.pm will do.

And it is not object oriented because that is overkill for getting a hash of data.

The nice thing is that it is only 162 lines including comments. It is as lightweight as I can make it.

The only advanced feature that I have added is that you can force it to return a value not as the scalar of the single checkbox you picked, but an array of one item (the value) so you can avoid special cases in the code where you actually do something. See the web page for more on this feature.

To read about it look here http://www.platypiventures.com/perl/modules/cgi_thin.shtml. And someday I will actually get around to bundling it properly for CPAN.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives