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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Get Perl to Automatically Look in Specific Directories for Scripts?

Status
Not open for further replies.

WingedKnight

Programmer
Apr 21, 2010
11
US
I have ActiveState Perl installed on a Windows machine.

Now, suppose I have scripts, including one called "SomeScript.pl", in this directory:

Code:
"C:\Example\Foo\Bar\"

How do I configure Perl to automatically look in that directory for scripts when it is passed a script path?

For example, from the command line, I can run...:

Code:
perl C:\Example\Foo\Bar\SomeScript.pl

...just fine.

But the following...:

Code:
perl SomeScript.pl

fails because Perl doesn't know to look in the "C:\Example\Foo\Bar\" directory. How do I configure Perl to automatically look in some specific directory for scripts when passed a script name from the command line?
 
Add the script location to the PATH environment variable.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind these jesus character, stars had to die for me to live.
 
ChrisHirst said:
Add the script location to the PATH environment variable.

By itself, that does not actually work, and...

Code:
perl SomeScript.pl

...will still fail, but I learned from somewhere elsewhere that this does work in combination with the -S switch:

Code:
perl -S SomeScript.pl

:)
 
Maybe that's a 'Windows thing', been a while since I ran anything on Windows.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind these jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top