I hate Perl. Hate it, hate it, hate it...
Nov. 25th, 2006 07:13 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Okay, all of you Perl aficionados who keep telling me what a nice language it is. I have a question for you. I'm trying to write a dirt-simple program to parse an input form using the standard CGI library on Unix. My code looks something like this:
Why, prithee tell, do the first two versions (both taken directly from the CGI documentation) keep insisting that $age and $age2 are empty strings, despite the dump quite happily showing that the age parameter is being passed in as expected? This damned language is so opaque (and the documentation so miserable) I'm at a dead end even trying to figure out where the data is hiding...
use CGI qw(:standard) ;
$query = new CGI;
my $age = $query->param('age');
my $params = $query->Vars;
my $age2 = $params->{'age'};
print $query->Dump();
Why, prithee tell, do the first two versions (both taken directly from the CGI documentation) keep insisting that $age and $age2 are empty strings, despite the dump quite happily showing that the age parameter is being passed in as expected? This damned language is so opaque (and the documentation so miserable) I'm at a dead end even trying to figure out where the data is hiding...
(no subject)
Date: 2006-11-26 01:09 am (UTC)(no subject)
Date: 2006-11-26 03:30 am (UTC)show your form please
Date: 2006-11-26 01:54 am (UTC)(no subject)
Date: 2006-11-26 02:06 am (UTC)then:
http://crschmidt.net/code.cgi?age=1
works.
So, it sounds like your setup might be broken?
(no subject)
Date: 2006-11-26 03:33 am (UTC)(no subject)
Date: 2006-11-26 04:06 am (UTC)In any case, sounds like you got it sorted.
(no subject)
Date: 2006-11-27 06:32 pm (UTC)Perl is actually a remarkably elegant language -- for one that's as big as it is. (that said, there's a lot of accumulated cruft, some of which isn't really as useful as originally intended -- like the mutating funny characters on the beginnings of variables, and the related differences in the syntax for accessing a thing and for accessing a reference to the very same thing. Much of this will change in perl 6).
But CGI.pm is a bloated and over-ambitious tool, and one I'd not normally recommend using -- you're better off using a smaller CGI library that doesn't try to also handle HTML creation -- or just jump to mod perl, depending on your platform.
(no subject)
Date: 2006-11-28 06:04 pm (UTC)Setting that aside, though: do you have recommendations for a CGI library? Everything I'd seen has tended to indicate that CGI.pm is The Library You're Supposed to Use for the purpose, but I agree that it's total overkill for my purposes, and I'm happy to consider something more concise. (Although, that said, I don't know how much flexibility I have in pulling new modules onto my system -- see previous comment about Big Commercial ISP...)
(no subject)
Date: 2006-11-28 06:45 pm (UTC)(no subject)
Date: 2006-11-29 12:28 am (UTC)