When using CGI.pm, you may also replace:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
With:
#!/usr/bin/perl -w
use strict;
use CGI qw(-no_debug :standard);
my $q = new CGI;
print $q->header; # prints default
# content-type,
# which is text/html
# rest of progam...
__END__
Notes: qw(-no_debug :standard) is
for disabling command line input
and only importing the standard
functions in CGI.pm, instead of
ALL of them -- which you probably
don't need.
$q is the same as $query in your
example. You can name that variable
anything you wish.
$q is your new CGI object, -> means
your actually pointing to a function
in CGI.pm. the text after the -> is
the function you would like to use.
i.e. $q->header;
This is your new CGI object ($q),
referencing the header()
function in the 'standard' set
of functions that you imported
from CGI.pm.
Finally, test your program, as you go,
from the command line like so, to test
for errors:
/path/to/perl -wc <program_name>
(where <program_name> is the name of
your script.)
Cheers!
| [reply] |
Can you explain that a bit more? I dont know what to do with the code you gave me...
or tell me where to get that CGI.pm thing at?
Thanks!
| [reply] |
CGI.pm should already be installed on your system as it
comes with Perl, I believe. Do perldoc CGI to see if it's
installed. It's a Perl module that gives you nice and easy
access to all of the CGI parameters passed in to your
script.
You should put
use CGI;
my $query = new CGI;
at the top of your script before you do anything like
my $name = $query->param('name');
| [reply] [d/l] [select] |