How to make perl script executable from anywhere on windows?

V

veg_all

I have ActivePerl installed and want to place all my scripts in one
directory but be able to execute them from anywhere. So if I type perl
myscript.pl from any directory/folder in windows dos prompt it will
run.
 
R

RedGrittyBrick

I have ActivePerl installed and want to place all my scripts in one
directory but be able to execute them from anywhere. So if I type perl
myscript.pl from any directory/folder in windows dos prompt it will
run.

Add the directory which contains your scripts to the PATH variable.

For example, if you have scripts x.pl, y.pl and z.pl in
C:\My\Perl\Scripts you can type these commands from any directory

D:\Temp> PATH=%PATH%;C:\My\Perl\Scripts
D:\Temp> x.pl
D:\Temp> cd \Other
D:\Other> x.pl

You can make the PATH change permanent as follows:
# From the desktop, right click My Computer and click properties.
# In the System Properties window, click on the Advanced tab.
# In the Advanced section, click the Environment Variables button.
# Finally, in the Environment Variables window, highlight the path
variable in the Systems Variable section and click edit. Add or modify
the path lines with the paths you wish the computer to access. Each
different directory is separated with a semicolon

Note that this has *nothing* to do with perl.exe being on the path or
file associations for .pl. The ActiveState installer will already have
taken care of both of these. I think the other responder has
misunderstood your question.
 
R

RedGrittyBrick

Which is a question about how to execute d:\my\onedirectory\myscript.pl
by typing `perl myscript.pl` when the current directory is c:\elsewhere.

The answer is to add d:\my\onedirectory to your path and type the
command `myscript.pl`.

The answer is *not* to associate the .pl filename extension with
perl.exe - the installer will already have done this.

http://aspn.activestate.com/ASPN/do...Winfaq4.html#How_do_I_associate_Perl_scripts_

Which is a document about how to associate the .pl filename extension
with the perl interpreter.

Associating pl with perl.exe does not help the OP achieve success with
c:\elsewhere> perl myscript.pl
when myscript.pl is in d:\my\onedirectory
which is what he said he wants to do.

Also about "Associate file types on the command line"

<exact instructions snipped>

Which *will* help the OP achieve success with
c:\elsewhere> perl myscript.pl
when myscript.pl is in d:\my\onedirectory
which is what he said he wants to do.

Note that my adviceIs *not* the same as PurlGurl's advice to associate the .pl filename
extension with the perl interpreter.

In my original response I added
PurlGurl said:
I am curious.

I provide the precise same information as you,

No you didn't.

With your having repeated what I wrote, but to a significantly
lesser degree of quality,

My advice was completely different.

why do you understand and I misunderstand?

Because I read the original posting more carefully.

Appears you are lying to readers just as McClellan lies to readers.

It is not a lie to say that associating the .pl filename extension with
the perl interpreter does not enable you to run a perl program by typing
`perl myscript.pl` when myscript.pl is not in the current directory.

Especially when the ActivePerl installer will already have made that
association.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top