Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hello world with perl

Status
Not open for further replies.

minus0

Programmer
Feb 20, 2003
73
US
Greetings all,

I am a newbie to the PERL world. Felt this could be an interesting scripting language so downloaded and installed ActivePERL and when I did a
perl -w f:\perl\eg\example.pl
from the command prompt instead of displaying a "hello world" kind of message, all it does is bring up the windows explorer with the path as c:\perl. I did tweak my PATH to include the PERL binaries.

please suggest what I need to get PERL running on my PC.
I am running on win 2000 PRO.

Thanks for your time and help
-0
 
Type path at the command prompt - does it display your perl installation location? Did you specify the right path - to the bin location - like:

C:\Perl\bin
Additionally you must start a new command prompt after adding the path - as Windows does not update your current command prompt automatically.

That being said your script should work with something as simple as the following:

print "Hello world\n";

Additionally you may want to navigate to the location of the perl script and then run:

prompt:perl -w example.pl

- just in case it is not parsing your directory specifications correctly.




-Chris Larivee
 
raklet - its the standard example.pl and it has
print "Hello from ActivePerl!";

Chris - took your suggestion and at the dos prompt I did a cd to where PERL is installed which is f:\perl\bin and did
f:\perl\bin\>perl ..\eg\example.pl
and got what I was hoping for.
then I cd'd to root as in f:\ and did
f:\>perl perl\eg\example.pl
and this too worked. so thanks a bunch for the help.
now question is do I have to keep changing to this path (as in F:\) and run my perl scripts or is there a work around?

I am including my path here
PATH=F:\Perl\bin\;C:\WINNT\system32;
so perl binary is included in the path so why do I have to change paths?

thanks once again for getting me started.
-0
 
Because when you set path from the command prompt, it no longer stores as a permanent system configuration. It is valid for that window only and is destroyed when you close the command line. To make it permanent, you have to use Windows stupid little gui for environent variables (or you can edit the registry if you are comfortable with that).

To change it permanently, you can either reinstall Active Perl and look for the option that asks if you want to add to the path, or you can

Right click on my computer,
Select properties,
Look for environment variables,
Look for Path in System Variables,
Edit path and append the location of perl binaries


Or you can edit this registry key directly (not recommended unless you are sure of what you are doing). Editing the registry also requires logging out and back in for it to take effect.

HKLM\System\CurrentControlSet\Control\Session Manager\Environment\Path

Double click on path and add the location of perl binaries to it.
 
Raklet,

I didnt set my path at the dos prompt and the path I included in my previous post is what is my environment PATH, I am sorry I wasn't explicit about that.

so again my path is

F:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;C:\Program Files\Common Files\Microsoft Shared\VSA\7.0\VsaEnv;

-0
 
if you can run from the command prompt at any directory:

perl -v

and you see the version of perl you are running, then you environmental settings are correct.
 
Stiddy,

I have been running my perl scripts (just a few liners) all day today from the directory where I have my Perl binary and after reading your post I thought I will try out your suggestion so did a perl -v from c:\ and it did give me my Perl version as you suggested and now I am able to even run programs from any directory (though I have no clue why its working today and didnt previously)

Thanks for your help
-0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top