1

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,

Kaspaar
  • 166
  • 2
  • 4
  • 20
  • Do you have all the correct file modes on your directories and this file? Do you have the path to this file correct in your URL? Probably need more info to be of any help... – Lucas Mar 20 '13 at 15:12
  • [Wed Mar 20 16:17:22.205165 2013] [win32:error] [pid 5420:tid 1656] [client ::1:52122] AH02102: C:/xampp/htdocs/test.pl is not executable; ensure interpreted scripts have "#!" or "'!" first line [Wed Mar 20 16:17:22.205165 2013] [cgi:error] [pid 5420:tid 1656] (9)Bad file descriptor: [client ::1:52122] AH01222: don't know how to spawn child process: C:/xampp/htdocs/test.pl – Kaspaar Mar 20 '13 at 15:18
  • this is what my error.log file from my apache server says – Kaspaar Mar 20 '13 at 15:20
  • um, `C:/...` indicates windows, but your `#!/usr/bin/perl` indicates unix... Which is it? – Lucas Mar 20 '13 at 15:20
  • i am running this on a xampp apache server on windows – Kaspaar Mar 20 '13 at 15:24

2 Answers2

2

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.

1

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.

Dinesh Patra
  • 1,125
  • 12
  • 23