in reply to RE: Re: First Script
in thread First Script

Well, if you are able, run the script from the command line. If your program fails to compile, that may be the problem.

Quick checklist:

Another thing to do (in test only, don't use this for production), is to add the following line to the script:
use CGI::Carp qw(fatalsToBrowser);
If your script actually gets as far as compiling and the program tries to run, this will output the error messages to your browser, which aids debugging. Make sure that you take this out when you move the code to production as there is no sense in giving hackers additional information.

From what you are describing, it sounds like the problem is not with your code, but with the configuration. You have your code in the wrong place or something.

Is there any chance that you made corrections to your code that you forgot to upload to the server?

Replies are listed 'Best First'.
RE: RE: RE: Re: First Script
by Smash8 (Initiate) on Jul 18, 2000 at 02:25 UTC
    Ovid, when I added the line

    use CGI::Carp qw(fatalsToBrowser);

    I got an error:
    Software error:
    Can't locate object method "new" via package "CGI" at .......
    So I presume that the program is compiling. And when I run it from the command line it's all good. Thanks a lot for helping a very bad perl programmer.

      Oh! This is a good sign. It means that your script is trying to run.

      Perhaps I should have been more clear. use CGI::Carp qw(fatalsToBrowser); does not replace use CGI;. I suspect that either you used it in place of use CGI; or you are trying to assign new CGI before the use CGI; statement. Either of those will produce the error you describe. Try the following:

      #!/usr/bin/perl -Tw use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $query = new CGI; # the rest of your code goes here.
      Note that use CGI; is before the new CGI; assignment.

      Also notice the -T switch on the command line. That's for "taint checking." You're going to hate this, but you really need to read perlsec and understand what's going on. If you start learning this early, you will save yourself a lot of problems down the road.

      Cheers,
      Ovid

      P.S.: Don't think of yourself as a bad Perl programmer, think of yourself as a new Perl programmer. There's a difference :)