Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run Perl files over XAMPP on Windows?

I am new to the Perl language, and I tried running it as I do for PHP files, by putting files in htdocs and then accessing them over localhost.

Below is the Perl file which I created, but wasn't able to run over localhost:

-----hello.pl---------------

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

like image 398
Webroots Avatar asked Oct 22 '11 14:10

Webroots


1 Answers

  1. Install xampp. during installation, Make sure that, you have checked perl to be installed.
  2. I assumed that, you have installed xampp in c:/xampp directory.
  3. Now go to c:/xampp/htdocs directory. Inside htdocs directory create a directory perl. Now inside the perl directory, make a file named hello.cgi .
  4. In hello.cgi write the following code snippet.

hello world program:

#!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-type: text/html\n\n";
print "Hello world."

Now start apache from xampp control panel. And in browser's url, enter localhost/perl/hello.cgi.

like image 74
Dinesh Patra Avatar answered Oct 05 '22 10:10

Dinesh Patra