in reply to error management...
in thread Newbie error management question

Well, I don't see anywhere where you are:
print $cgi->header();
or the like -- so that would be the first thing I would check out.

To further test things I would run the code at the command line and see what is actually getting printed out. This should illuminate alot. You can run it at the command line by doing..

./foo.cgi var1=val1 var2=val2
where "foo.cgi" is your actual program name; "var1" etc, are each of the variables you are referencing; and "val1" etc, are values to test in those variables.

The script should then run and you will be able to see what is trying to be sent to the browser.. you will like see something strange appear -- and that will likely be your error.

Replies are listed 'Best First'.
Re: Re: error management...
by ChemBoy (Priest) on May 15, 2001 at 22:48 UTC

    He's not using CGI (which you really should do for anything of any size... check use CGI or die; for why), he's printing the header manually, and it looks like it's right.

    Given that, it's likely an error message of some kind printing to STDERR before you print the header, shambright--is there anything else in the error log entries that might indicate that? Usually when I pull that stunt, it comes out with something like "failed to emit valid header (got 'Use of uninitialized value at foo.pl line 34')" .



    If God had meant us to fly, he would *never* have give us the railroads.
        --Michael Flanders

      So much for my reading comprehension, I missed the
      print "Content-type: text/html\n\n";
      But he is using CGI, check at the start of the code.
      #!/usr/bin/perl -w # NEEDED Variables $basedir = "/home/**/**"; $linkscgi = "http://www.foo.cgi"; # use form to get the data use CGI qw(:standard); $query = new CGI;
      Now I am going to have to look a little closer
        Ah-ha!

        You are using "perl -w", which is good; But you are failing to listen to the warnings I believe. If you run it, you will see that you get a warning

        Name "main::basedir" used only once: possible typo at ./index.pl line +5.
        A simple perl -c index.pl would have turned up this warning as well.

        updated Removed incorrect information regarding warnings and STDOUT

      All right, I think I am making progess.... I ran the script from the command line, (using the suggestion from Sifmole, thank you)

      To avoid "use of unintialized value" errors, I had to add some lines to check for NULL occurances of the form variables (and $TRACKER - which gave a NULL value from the command line{???}):

      $TRACKER = $ENV{'HTTP_REFERER'}; if (!($TRACKER)) { $TRACKER = $ENV{'REMOTE_ADDR'};} #added if (!($TRACKER)) { $TRACKER = ""; } # why would these ENV variables BOTH be blank ??? $client_email = $query->param('email'); #added if (!($client_email)) { $client_email=""; } chomp($client_email); #added to other query vars...

      This seems somewhat redundant, BUT... those first few variables were happening BEFORE I sent the headers.

      is there a better way to assure that the form values that are needed are not NULL before proceeding?