Debugging internal server errors (premature end of script headers) part 7

Other errors

There's a whole bunch of other errors that than occur within your script here are some of them.

Global symbol "$agent" requires explicit package name at test.cgi line 21.

This is an easy one. What this means is that at the top of the script is 'use strict' and when you use 'strict' every variable has to be 'declared'. Above this line number somewhere, not within any part within parenthesis ('{ }'), put:

    my $agent;
(remember the semi colon at the end of the line!!!) using whichever variable it stated needed it.

 

Can't locate object method "main" via package "style" (perhaps you forgot to load "style"?) at test.cgi line 66.

Line 66:

    print main style;
Simple one to fix - anything that gets printed needs to be within '" "'. Change line 66 to:
    print "main style";

 

Undefined subroutine &main::mysub called at test.cgi line 91.

This is stating that on line 91 of your script, a subroutine is called that doesn't exist. The '&main' refers to the script itself - somewhere in that script where it's called should be line saying 'sub mysub'. Check for spelling errors in the sub name, or the '&mysub' spelling on line 91.

Can't find string terminator "|" anywhere before EOF at test.cgi line 498.

Check on line 498 of your script, and it should be starting a print statement. This one in particular uses:

    print qq|
At the end of what it prints out, it should end with:
    |;
Check if this exists - if it doesn't, put it in.

 

This particular error can cover any kind of string terminator. What it's looking for is what was used to start off the print string, should finish it off. The formatting of this is 'qq' then what you use - in the case above '|' - your text to print, then the closing '|' - then a semi-colon to finish off the line.

A few examples, the first one is the correctly formatted version of the one that generated the error above:

print qq|stuff gets printed here...|;
print qq[stuff gets printed here...];
print qq(stuff gets printed here...);
print qq!!stuff gets printed here...!!;