Avatar of dwabbott
dwabbott
 asked on

Help in getting started with Perl

I want to start learning Perl and be able to run programs on my PC.  I am using Windows XP.  I have books on Perl and I have downloaded a version of Perl from www.strawberryperl.com, but I don't know where to go to start putting in commands.  Anything that I try to enter at the C:\ prompt is not recognized.   Can you help me get started?
SoftwarePerl

Avatar of undefined
Last Comment
dwabbott

8/22/2022 - Mon
SOLUTION
Shizzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
whosbetterthanme

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
FishMonger

You didn't say what you entered at the command prompt so it's difficult to say what you did incorrectly.

Were you trying to execute a Perl script or were you trying to execute a Perl "one liner" where the perl commands/code is entered directly at the command prompt instead of from a text file?

If perl was installed correctly, the installation process should have added the location of perl to the path environment var as well as create a .pl filetype association.  However, both of those are install options which could have been unchecked and hence not done.  If that's the case, then you'll want to do that manually.  Once that is complete, you won't need to specify the full path to perl.exe, as suggested by Shizzo, when executing your code.

Creating the file type association:
How to change or select which program starts when you double-click a file in Windows XP

Adding perl to the path:
How To Manage Environment Variables in Windows XP

When writing Perl scripts ALWAYS begin your scripts with the strict and warnings pragmas.
#!/usr/bin/perl

use strict;
use warnings;

Open in new window

Those pragmas will point out lots of common coding mistakes.
FishMonger

Here's a good
Perl Beginners' Site.
dwabbott

ASKER
(I apologize for the delay in answering - for some reason an answer that I wrote did not post.)

Thank you all for your replies - I am still at ground zero, however.  I have downloaded the Strawberry Perl program and then at the C prompt I enter the #!/usr/bin/perl command but it does not recognize the #!.  I get to the C prompt from the start button, All Programs, Strawberry Perl, then the ‘Perl (command line)’ prompt for C:\  -  I tried to follow the suggestions given but I must be doing something wrong.  Where should I be to be able to enter a command starting with ‘#!’ and start in a program, such as hello world?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
FishMonger

Put your code in a text file.

Write your script
c:\testing>type hello.pl
#!/usr/bin/perl

# these 2 pragmas should be in every Perl script you write.
use strict;
use warnings;

print "Hello World!\n";

Open in new window

Execute the script
c:\testing>hello.pl
Hello World!
FishMonger

You can also run code directly from the command line, which is called a perl "one liner".

c:\testing>perl -e "print qq(Hello World!\n)"
Hello World!


However, when first stating out, you should stick with using scripts (code in text files).
dwabbott

ASKER
Thanks for your reply - I made a file in Word called hello.pl - I went to the C prompt and entered testing>type hello.pl, and get the following:
   'testing' is not recognized as an internal or external command, - - etc.
So it continues to not recognize my inputs at the C prompt.  I notice that at the C prompt I see C:\>, whereas you have simply C:\  -  does this make a difference?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
dwabbott

ASKER
I tried the one-liner  -  
c:\testing>perl -e "print qq(Hello World!\n)"

Same error message.  What about the '>'?  Is this a factor?
ASKER CERTIFIED SOLUTION
FishMonger

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
dwabbott

ASKER
FishMonger - Got it!  There were some steps I was not familiar with as I am not well versed in this area.  However, I finally figured out the obvious steps and did the following:
  First - I made a directory named testing
  second, I typed in the little program on notepad and named it C:testing/hello.pl
  third I went to the C:\testing> prompt and typed in 'type hello.pl' and it worked fine.

I knew it was simple!  Thanks very much for your help!
dwabbott

ASKER
I awarded three contributors, noted on the last comment for each -
  FishMonger  350
  whosbetterthanme  100
  Shizzo 50
I did not award any points to myself
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck