CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Setting up Perl

 



Comosus
New User

Jul 20, 2010, 4:25 AM

Post #1 of 5 (469 views)
Setting up Perl Can't Post

I'm new to Perl and programming languages in general. I have some experience of using the command prompt while learning to use Linux.

I have just installed ActivePerl on my Windows 7 computer and I'm trying to follow the 'Learning Perl' book (Schwartz & Phoenix).

In chapter 1 (yes, shamefully I get stuck here!), it asks to type in 'perldoc -u -f atan2' as a command, but the command is not recognized. I also tried typing in 'perl -v', as suggested by an online tutorial, and get the same problem.

I also had an odd problem with the 'Hello, world!' script. It loaded with Perl, but the window it was printed in only appeared for a fraction of a second before vanishing again. How can I make it stay visible?


BillKSmith
Veteran

Jul 20, 2010, 5:58 AM

Post #2 of 5 (463 views)
Re: [Comosus] Setting up Perl [In reply to] Can't Post

Your last question is easy. Run your perl programs from a command window. The #!perl.... line does not work in windows. You must type:


Code
  

perl hello_world.pl



Another approach is to add an input operator "<>" to the end of your program. Now when you start the program by double clicking its icon the program does not end and close its window until the user types a character.



In active state perl, the perldoc command is implemented as a .bat file. Find perldoc.bat and make sure that it is in your path. It uses a default pager. Perhaps that is not available in Windows 7. Try setting the environment variable PAGER to refer to your favorite editor.
Good Luck,
Bill


FishMonger
Veteran / Moderator

Jul 20, 2010, 6:24 AM

Post #3 of 5 (461 views)
Re: [Comosus] Setting up Perl [In reply to] Can't Post

The main problem is that you didn't install perl correctly. By default, the installation process will create a .pl file type association and will add the perl/bin directory to your path environment. Apparently you removed the checkmarks on one or both of those install options.

The problem of the window not staying open when you execute the script by "double clicking" is a standard Windows "feature". The same problem would occur if you run the dir command via "Start -> Run". You should open a cmd (command prompt) window then run your script from the prompt.


FishMonger
Veteran / Moderator

Jul 20, 2010, 6:30 AM

Post #4 of 5 (460 views)
Re: [BillKSmith] Setting up Perl [In reply to] Can't Post


In Reply To
Your last question is easy. Run your perl programs from a command window. The #!perl.... line does not work in windows. You must type:


Code
perl hello_world.pl



If perl is installed correctly, then you can simply execute the script as:

Code
C:\>hello_world.pl



In Reply To
Another approach is to add an input operator "<>" to the end of your program. Now when you start the program by double clicking its icon the program does not end and close its window until the user types a character.

Opening and running the script in a command prompt window would be a better solution.


BillKSmith
Veteran

Jul 20, 2010, 11:13 AM

Post #5 of 5 (450 views)
Re: [FishMonger] Setting up Perl [In reply to] Can't Post

Thanks for the correction. I missed that change when I upgraded to XP.

I agree that that is usually the best way to execute a perl program. However, I do have a very small number of programs which I prefer to run by clicking a shortcut on my desktop. These programs depend on some variation of the input technique to display their final results.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives