Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Where does perl looks for perl skripts [Answered]

by Jenda (Abbot)
on Sep 21, 2014 at 01:33 UTC ( [id://1101418]=note: print w/replies, xml ) Need Help??


in reply to Re: Where does perl looks for perl skripts [Answered]
in thread Where does perl looks for perl skripts [Answered]

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.

Replies are listed 'Best First'.
Re^3: Where does perl looks for perl skripts [Answered]
by Laurent_R (Canon) on Sep 21, 2014 at 21:26 UTC
    Well, if you type:
    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.

      Change that to

      C:\>perl -S foo.pl

      And, no, the environment is not crippled, the environment is different!

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1101418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-19 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found