perl doesn't look anywhere but where you specify. For example,
- perl foo.pl looks for foo.pl in the current directory of the current drive.
- perl bar\foo.pl looks for foo.pl in subdir bar of the current directory of the current drive.
- perl \bar\foo.pl looks for foo.pl in subdir bar in the root directory of the current drive.
- perl d:foo.pl looks for foo.pl in the current directory of the specified drive.
- perl d:bar\foo.pl looks for foo.pl in subdir bar in the current directory of the specified drive.
- perl d:\bar\foo.pl looks for foo.pl in subdir bar in the root directory of the specified drive.
- perl \\host\share\bar\foo.pl looks for foo.pl in subdir bar in the specified share of the specified host.
If you want Windows to search the path for foo.pl, you'll have to ask Windows to execute foo.pl instead of perl. Some configuration may be required.
| [reply] [d/l] [select] |
Hmm, this is a Windows question rather than a Perl question. Essentially, if you type:
C:\>perl foo.pl
Perl will look in the current directory. But this is not Perl deciding that, but Windows. It is Windows that is looking for the files you are using, just as if you type:
C:\>copy foo.pl bar.pl
the copy program will look in the current directory for the foo.pl program to make another copy of it under another name.
But you can set up various things under Windows to change or improve that behavior to a certain extent.
| [reply] [d/l] [select] |
It is very much a Perl question and Windows doesn't care about anything other than the first item on the command line. Even less than Unix does actually. The Windows command line processor doesn't know what do the parameters you enter for the executable you are asking it to start mean and unlike the Unix shells it doesn't even attempt to process the wildcards! It will search the list of directories in the PATH variable for files called "perl" plus any of the extensions specified in the PATHEXT variable and start that executable passing it the "perl foo.pl" line and it's up to the program to split the parameters and process them.
You may instruct Perl to search the directories in PATH for fool.pl by adding the -S flag: perl -S foo.pl, but it's gonna be perl doing the search, not "Windows".
You can also add .pl into the PATHEXT and then, assuming .pl is mapped to perl.exe, call your scripts by their name, without the "perl" and even without the extension. That is provided that PATHEXT contains .pl and foo.pl is in a directory in PATH, you can call the script by just C:\> foo.
Jenda
Enoch was right!
Enjoy the last years of Rome.
| [reply] [d/l] [select] |
C:\>perl foo.pl
and if you can tell Perl to look in other places than the current directory, then you have to teach me how to do it, because I must be ignorant on that.
(To tell the truth, I am using Perl mostly, and by far, on Unix or Linux systems, and also VMS systems; and when I have to use it on Windows, I do it most often under Cygwin, because bash is so much better than the Windows command environment. Sometimes I have to use Strawberry Perl or Active Perl under Windows, and, each time, I wish I did not have to do that, because, as you possibly implied but did not say, the environment is so much crippled. So, if you can show me good ways of doing it, I'll very happily take them and be very grateful to you.)
But don't tell me that you have to configure the PATH (or PATHEXT) environment variable to do that and, at the same time, tell me that this is a Perl question and not a Windows question, because PATH configuration is pure Windows, nothing to do with Perl.
And yes, you can map the .pl extension to execute a script (without having to use the perl command), but this is definitely not the question asked in the OP, and this is again a pure Windows configuration issue, nothing to do with Perl itself.
| [reply] [d/l] |
just wanted to add a comment here as well, may be off topic or may not.
i had created a script with the help of the community that gathers md5's (which gathering md5's is obviously NOT what your wanting to do, i am just using this as an example) of each file in a specified directory or single files. i then used a tool to pack the script into an executable file and then put that into the system32 folder. then i simply open cmd in the current explorer directory and type the packed exe name and directory or file's name i want to get md5's of and viola. works great though i do not think this is what you were after, it /could/ help some future readers in certain cases. | [reply] |