Student needs help with CGI.pm (I think)

Discussion in 'Perl Misc' started by Gary Schenk, Sep 25, 2003.

  1. Gary Schenk

    Gary Schenk Guest

    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.
     
    Gary Schenk, Sep 25, 2003
    #1
    1. Advertisements

  2. Gary Schenk

    Sam Holden Guest

    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.
     
    Sam Holden, Sep 25, 2003
    #2
    1. Advertisements

  3. Gary Schenk

    Gary Schenk Guest

    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.
    Yes, I ran perl -c and got the "too late for -T option" message. Maybe i am
    being impatient, but it's bugging me.
     
    Gary Schenk, Sep 25, 2003
    #3
  4. Gary Schenk

    Sam Holden Guest

    [snip CGI script calling dump()]
    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.
    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.
     
    Sam Holden, Sep 25, 2003
    #4
  5. Gary Schenk

    Gary Schenk Guest

    It definitely says print dump();
    Of course, you are absolutely correct! That was it. It runs as it should
    now.
    I checked for an errata and nothing there. I'll send an email to the
    authors.
    Thanks for the tip.
    I see.

    Thanks for the help. Lots of information was packed into this exchange!
     
    Gary Schenk, Sep 25, 2003
    #5
  6. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    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-----
     
    Eric J. Roode, Sep 25, 2003
    #6
  7. Gary Schenk

    Gary Schenk Guest

    Eric J. Roode wrote:

    <snip>

    "Writing CGI Applications with Perl". I've just started it, along with
    "Learning Perl".
     
    Gary Schenk, Sep 26, 2003
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.