Perl cgi help [Answered]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Perl cgi help [Answered]

Postby Ragnarok210 » 17. September 2012 17:13

Hello, I would like to know how do you run perl or cgi script with XAMPP?

Here is portion of my code that I wrote while back, that does some ajax work...
Code: Select all
#!C:\xampp\perl\bin\perl.exe

#open data file to get all previous received data
open IN, "data.txt" or die "Cannot open: $!\n";
@DATA = (<IN>);
close IN;
#Will append new received data into data.txt
open OUT, ">>data.txt" or die "Cannot open: $!\n";
#receive data via POST method
read (STDIN, $data, $ENV{'CONTENT_LENGTH'});
@data_array = split ("\&", $data);
#STDOUT HTML header
print "Content-type: text/html\n\n";

#do something here.....

I don't think there's any problem with the code, and I changed the shebang line...
I drop the folder in htdoc and cgi-bin folder, tested both. In the browser only the html works, and nothing else

nothing in the error log...

any help would be appreciated, thanks...
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: Perl cgi help

Postby JonB » 17. September 2012 17:53

well - what did you name the file?
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Perl cgi help

Postby Ragnarok210 » 17. September 2012 18:01

cgi = chatCGI.cgi
data.txt
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: Perl cgi help

Postby JonB » 17. September 2012 18:30

OK -

A: hopefully this is something beyond this:

Code: Select all
#STDOUT HTML header
print "Content-type: text/html\n\n";


B: Test this URL:

http://localhost/cgi-bin/perltest.cgi

It SHOULD show you this:

GCI with MiniPerl
CGI with MiniPerl is ready ...

misspelling and all - :shock:

Good Luck
:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Perl cgi help

Postby Ragnarok210 » 17. September 2012 18:49

yes, it works...
can you explain what that does?

btw, after I did more tests, such as a simple cgi and .pl in cgi-bin and it works fine...
I believe the problem is the ajax, when the script make a request to write to file and read from file, nothing happens...
I have tested on a different server environment, it works just fine...

I wrote this couple years ago, not sure if there are any changes that can cause the problem...
Last edited by Ragnarok210 on 17. September 2012 19:55, edited 2 times in total.
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: Perl cgi help

Postby JonB » 17. September 2012 19:36

My purpose was to ensure that XAMPP was configured right and the Perl interpreter was working correctly.

I can explain what the problem is, but I don't know how you made it work somewhere else without this method (I know 'some Perl' but I do not wear the habit).

What is in a Perl Script is 'code' and other "stuff" - if the script language is not Perl - the 'other code' needs to be set off by a script tag, so Perl knows to 'ingore this at compilation - soemthing else will figure it out, not you, Perl ' - YES! Perl is compiled! its a JIT compiler that reads the code once, bascially at runtime via evals.

read these -
http://www.webmasterworld.com/perl/3128782.htm

http://www.perlmonks.org/?node_id=635467

AFAIK - nowadays, the prefered method is to use XML to exchange data between Perl and Javascript.

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Perl cgi help [Answered]

Postby Ragnarok210 » 17. September 2012 19:54

Thanks for the explanation, I have figured out the problem...
[edit], it's because I make a small modification on printenv.pl file, and for whatever reason it causes problems...
so I paste back the backup file, and now it's working fine...
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 59 guests