Student needs help with CGI.pm (I think)

G

Gary Schenk

I'm using this script to get data from a HTML form. All I get is an error:
premature end of script headers.

This is run on a shared hosting web site. Could this be a problem with
CGI.pm? I'm very new, and have read this over carefully, so it must be a
configuration problem. I realize you guys can't help with that, but could
you tell me if the script is OK?

#!/usr/bin/perl -wT
use strict;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
print header;
print dump();

The Carp module is on the server, and the permissions are correct on the
script. a "locate" command shows that CGI.pm is on the server, also.

Thanks.
 
S

Sam Holden

I'm using this script to get data from a HTML form. All I get is an error:
premature end of script headers.

This is run on a shared hosting web site. Could this be a problem with
CGI.pm? I'm very new, and have read this over carefully, so it must be a
configuration problem. I realize you guys can't help with that, but could
you tell me if the script is OK?

#!/usr/bin/perl -wT
use strict;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
print header;
print dump();

The Carp module is on the server, and the permissions are correct on the
script. a "locate" command shows that CGI.pm is on the server, also.

dump() is a perl built in function that causes the process to dump core.

Calling it will naturally make you script not work.

So why are you calling it? Case matters.

Also, run the script at the command line to get it working before
running it via CGI, any errors will be much easier to see.
 
G

Gary Schenk

Sam said:
dump() is a perl built in function that causes the process to dump core.

Calling it will naturally make you script not work.
Interesting.


So why are you calling it? Case matters.

Long story, but I'm having to teach myself Perl and CGI. I'm taking an
extended education class starting next week. In the meantime I've been
reading a book on CGI and Perl. This is an example script from the book. It
is supposed to output a webpage with information taken from a form. This
script is to show how easy CGI.pm makes this task. Basically, I'm quite
ingnorant, and want to know if it is the script or a configuration problem.
Also, run the script at the command line to get it working before
running it via CGI, any errors will be much easier to see.

Yes, I ran perl -c and got the "too late for -T option" message. Maybe i am
being impatient, but it's bugging me.
 
S

Sam Holden

Sam Holden wrote:
[snip CGI script calling dump()]
Long story, but I'm having to teach myself Perl and CGI. I'm taking an
extended education class starting next week. In the meantime I've been
reading a book on CGI and Perl. This is an example script from the book. It
is supposed to output a webpage with information taken from a form. This
script is to show how easy CGI.pm makes this task. Basically, I'm quite
ingnorant, and want to know if it is the script or a configuration problem.

Are you *sure* the book doesn't say:

print Dump();

Since that would do what you describe.

As I said, case matters.

If it really says dump(), then I'd be looking for an errata and making
the corrections it specifies. If there isn't one I'd be looking for a
new book.
Yes, I ran perl -c and got the "too late for -T option" message. Maybe i am
being impatient, but it's bugging me.

So use perl -c -T.

See 'perldoc perldiag' if you don't understand a perl diagnostic.

Though what I meant was:

../test.cgi

Or whatever the CGI was named, to run it on the command line.
 
G

Gary Schenk

Sam said:
Sam Holden wrote:
[snip CGI script calling dump()]
Long story, but I'm having to teach myself Perl and CGI. I'm taking an
extended education class starting next week. In the meantime I've been
reading a book on CGI and Perl. This is an example script from the book.
It is supposed to output a webpage with information taken from a form.
This script is to show how easy CGI.pm makes this task. Basically, I'm
quite ingnorant, and want to know if it is the script or a configuration
problem.

Are you *sure* the book doesn't say:

print Dump();

It definitely says print dump();
Since that would do what you describe.

As I said, case matters.

Of course, you are absolutely correct! That was it. It runs as it should
now.
If it really says dump(), then I'd be looking for an errata and making
the corrections it specifies. If there isn't one I'd be looking for a
new book.

I checked for an errata and nothing there. I'll send an email to the
authors.
So use perl -c -T.

See 'perldoc perldiag' if you don't understand a perl diagnostic.

Thanks for the tip.
Though what I meant was:

./test.cgi

Or whatever the CGI was named, to run it on the command line.

I see.

Thanks for the help. Lots of information was packed into this exchange!
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It definitely says print dump();

Which book are you using? Lord knows there are enough bad Perl books out
there. :-/
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP3LQRmPeouIeTNHoEQJXKQCeMn39bUHfpq+1/FrZmoDuL2l00iEAn1NQ
sLMa8MBisQi2yYzekhuHVHL4
=nFYb
-----END PGP SIGNATURE-----
 
G

Gary Schenk

Eric J. Roode wrote:

Which book are you using? Lord knows there are enough bad Perl books out
there. :-/
- --
Eric
<snip>

"Writing CGI Applications with Perl". I've just started it, along with
"Learning Perl".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top