Page 1 of 1

help gettin started with xampp and perl

PostPosted: 24. November 2007 06:05
by awesomebill61
i just installed xampp and the perl add-on on my system.

reading through the perl manual and documentation, they talk about locating the interpreter in the first line of every script on unix systems, and go into some detail of the alternatives to use on windows systems.

i'm running my xampp on windows and would like to know what line i need to put into my code to get it to run.

thank you!

PostPosted: 24. November 2007 08:18
by Izzy
i'm running my xampp on windows and would like to know what line i need to put into my code to get it to run.

The line to add to every .cgi or .pl file is often referred to as the shebang.
For example, in this snippet:
Code: Select all
#!"C:\xampp\perl\bin\perl.exe"

use CGI;

$form=new CGI;

$f_name=CGI::escapeHTML($form->param("f_name"));
$f_email=CGI::escapeHTML($form->param("f_email"));
$f_text=CGI::escapeHTML($form->param("f_text"));
etc.etc.


It goes at the very top of these files and refers to the absolute path of the Perl interpreter - perl.exe - no spaces above this line.

It looks like this but your path to perl depends on where you installed XAMPP:
#!C:/xampp/perl/perl.exe

If you use the Windows path format and\or you have spaces in a directory name then you need to enclose the path in quotes:
#!"C:\xampp\perl\perl.exe"

From a command console prompt you can issue commands to verify your perl version and what perl switches can be used on the shebang line or from a command prompt:
http://community.apachefriends.org/f/viewtopi ... 7109#87109


===========================================
1. The new DeskTopXampp Launch Control for XAMPP / XAMPPlite
Posted by Ridgewood available from Ridgewood'sDTX web site

2. Build Rich AJAX Applications - Faster
TIBCO General Interface Pro Edition but FREE and Open Source
Fully working with NO donations required to get a user/password
===========================================

PostPosted: 25. November 2007 00:21
by awesomebill61
okay, so i created this simple script:
Code: Select all
#!"C:\xampp\xampp\perl\bin\perl.exe"

print "Hello World";


when i try to open it up in my web browser, i just get a blank white page.

PostPosted: 25. November 2007 01:07
by Izzy
Try to follow the example scripts in the xampp\cgi-bin directory for clues about perl code.

Try this for yoursimplescript.cgi:
Code: Select all
#!"C:\xampp\xampp\perl\bin\perl.exe"

print "Content-type: text/html\n\n";

print "Hello World";

You have to tell perl what type of content requires printing.

Other things to check for:
The server is running?

You put yoursimplescript.cgi in the cgi-bin.

You went through the server so that perl.exe is parsed.
http://localhost/cgi-bin/yoursimplescript.cgi

Or you put yoursimplescript.cgi in the htdocs directory.

You went through the server so that perl.exe is parsed.
http://localhost/yoursimplescript.cgi

BTW
C:\xampp\xampp\ is not a good location to install XAMPP to which may course some issues - although is not related to your cgi issues.

Try to install to just C:\xampp
http://www.apachefriends.org/en/xampp-windows.html#1156



===========================================
1. The new DeskTopXampp Launch Control for XAMPP / XAMPPlite
Posted by Ridgewood available from Ridgewood'sDTX web site

2. Build Rich AJAX Applications - Faster
TIBCO General Interface Pro Edition but FREE and Open Source
Fully working with NO donations required to get a user/password
===========================================

PostPosted: 25. November 2007 02:45
by awesomebill61
thank you!
the content-type line fixed it and now the script outputs.

i'm going to reinstall xampp in a top level directory to prevent any future problems.

two more questions i have:
what are the differences between the .pl extension and the .cgi extension, and which is 'better'?

what are the differences between the cgi-bin and the htdocs directory?