Search code examples
perlinternal-server-erroruse-strict

"use strict;" line in perl causing a simple print script to fail to run


I installed apache and perl a few days ago and have been successful in running a few scripts, but I have not been able to get a single script to run after putting the "use strict;" line in. All I see upon adding that line is a very generic "Internal Server Error" with ZERO unique information.

Here's a script that does gives the error:

#!/usr/bin/perl

use strict;

print "Content-Type: text/html", "\n\n";

print "Hello World";

Cannot find anyone else having this problem, really puzzling me. Could it be some setting in my installation of perl or something?


Solution

  • Always check the error log in situations like this. Let it tell you what's wrong.

    There are at least three likely possibilities:

    1. The script is not executable, and so will not run. (unix specific)
    2. #!/usr/bin/perl does not exist and so can't be executed.
    3. Your @INC is messed up some how, and so strict cannot be found.

    Your error log should be able to say if it is one of these fairly quickly.