Question

I am using xampp 1.8.1 on windows 7 and want to use it for perl, but when i execute even the most easy hello world perl script it gives me an error 500. Does anybody know what i am doing wrong? this is my 'hello world script:

 #!/usr/bin/perl
print "Hello World.\n";

Thanks in advance,

Was it helpful?

Solution

Change the shebang line to actually point to your Perl path, for example:

#!c:/Strawberry/perl/bin/perl.exe

You can quote it if necessary:

#!"c:/Program Files/Perl/perl.exe"

Note that in Perl you can always use forward slashes for directories even on Windows (and this is preferred because it avoids messy escaping issues).

On Windows, the path in the shebang line is not normally used for execution. Thus the convention is often to use #!/usr/bin/perl for compatibility with Linux. However, Apache actually does use this path, so it needs to be set accordingly.

OTHER TIPS

The correct code is:

#!C:\xampp\perl\bin\perl.exe

# The above line is perl execution path in xampp

# The below line tells the browser, that this script will send html content.
# If you miss this line then it will show "malformed header from script" error.
print "Content-ype: text/html\n\n";
print "Hello world."

In xampp the perl execution path is C:\xampp\perl\bin\perl.exe Also, you can save a perl file ith extension .pl, .pm, .cgi . But for browser use, I would prefer .cgi extension.

I think this would help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top