perlactivestate

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


I have ActiveState Perl installed on a Windows machine.

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

"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...:

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

...just fine.

But the following...:

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?


Solution

  • This is possible in at least some Windows Perls (I'm using Strawberry 5.24).

    1. Add the desired path to your Windows PATH. Control Panel > System > Advanced system settings > Environment variables

    2. Run perl with the -S switch.

      perl -S program.plx

    All the usual headaches of managing PATH apply (e.g. the first file with that name gets run).