Question:
I've got some problems with Perl!?
Sam Macro
2011-08-14 12:43:44 UTC
Right, I have installed Strawberry Perl on Windows XP. I tried very simple stuff like:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "

Hello World

\n";
(or similar)

I am typing this in Perl (command line). I am pretty sure this is the wrong place to type it so I wondered if anyone could tell me where I am actually supposed to write it. This would be much appreciated!!

Also, when I have typed it where do I run it or look at the result.

Thanks so much!!
Three answers:
Toad
2011-08-14 13:25:52 UTC
I've never used Strawberry Perl but I can't imagine it's too different from ActivePerl which I use ( http://www.activestate.com/activeperl/downloads ).



Open a command prompt by pressing the Windows Logo Key + R and typing cmd and hit OK. You can type this in to know if perl is installed correctly:



perl -version



If things are good it will display a message telling you which version you have. Otherwise it will give an error and then it's either not installed correctly or is not added to the Windows Environment Path.



Assuming it's installed correctly you can execute Perl scripts by typing this into the command prompt:



perl /path/to/your/program/file



If you run yours it will literally print to the screen the text you entered. What it looks like you're trying to do is display the output in an HTML page. This is done via a web server which is configured to execute a Perl script (often called CGI) and then send the result to a browser. This is more complicated but you can do web searches about it.



You can also write and execute Perl using an IDE such as Eclipse with the EPIC plugin:

http://www.epic-ide.org/download.php
Takanori Kawai
2011-08-17 22:12:06 UTC
Where is your Web server?



Did you install Apache or something?

http://httpd.apache.org/docs/2.2/platform/windows.html

Or I usually use xampp with perl on Windows.

http://www.apachefriends.org/en/xampp-windows.html
martinthurn
2011-08-15 23:18:40 UTC
Excellent answer up there. I would like to add, if you're intending to do CGI programming, you must use the CGI module. It makes your life 100 times easier 8-)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...