You are using the object oriented version of the syntax, whereas jeff is using the 'traditional' syntax. I dont think there is any fundamental difference between the functionality available one way or the other, just whether you are familiar with OO notation or not I guess.
It says I need the CGI.pm module! Where do I get that? The error is on line three. @INC contains ./lib /site_perl is part of the error. Here's the whole script:
#!/usr/local/bin/perl
use CGI qw{:cgi};
my $name = param('Name');
my $email = param('Email');
if($ENV{'Request_Method'} eq 'GET') {
print <<EOF;
Content-Type: text/html\n\n
<h1>You cannot use the GET method for this script.</h1>
EOF
}
else {
print <<EOF;
Content-Type: text/html\n\n
Name: <b>$name</b>
Email: <b>$email</b>
EOF
}
My question is how to I add the CGI.pm module? And is this script insecure or incorrect at this point?
Many thanks!!
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
I dont think there is any fundamental difference between the functionality available one way or the other
Actually, in larger modules using object oriented code actually yields better performance than the procedural style. However, Stein made CGI.pm a little funky by making it _both_ object oriented and procedural. As a result of added code to make that work the oo style is actually a little slower with that module.
It says I need the CGI.pm module!
It should be a part of the standard Perl distribution. But based on what @INC contains (this is the array that holds the paths to be searched for imported files) it looks like the path for the Perl libraries are not being checked. Add this:
And is this script insecure or incorrect at this point?
You can (and should) use the -T switch to enabled taint mode (this enables a set of special security checks done by Perl). But a couple fixes I see off hand, 'Request_Method' as a key value in the ENV hash should be all uppercase, $ENV{REQUEST_METHOD}. And also, since the CGI module can handle both GET and POST requests there is no need for this check at all.
It should go in the 'lib' directory, and the lib directory should be in the same path as the script. So relative to the script the path would be ./lib, which is already in the @INC array.
No, relative to the script. If the script is in /cgi-bin/yourscript then the module goes in /cgi-bin/yourscript/lib. If the script is in /cgi-bin then the module goes in /cgi-bin/lib.
Can't locate CGI/Util.pm in @INC (@INC contains: . /lib /site_perl) at /lib/CGI.pm line 27.
BEGIN failed--compilation aborted at /lib/CGI.pm line 27.
BEGIN failed--compilation aborted at qSignup.pl line 3.
This is very agrivating! Here's what my setup is like:
I am getting a new host. The script will work, but every time I add another module (after taking 30 minutes to find the module on another computer, put it on a floppy, and bring it back to this one) it says I'm missing a different one and I have to create another folder to put it in!
I'm getting a new host. Thanks for your patience, Jeff. Constant.pm is missing in @INC this time, but I'm just going to forget the whole darn thing! It's off to a new host...
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
Bookmarks