Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to emulate the Unix command "which"

Reply
Thread Tools

How to emulate the Unix command "which"

 
 
chris-usenet@roaima.co.uk
Guest
Posts: n/a
 
      08-19-2005
Ilya Zakharevich <nospam-> wrote:
> [A complimentary Cc of this posting was sent to <>]


No thanks. This is usenet.


>> A quick way for a single command is:
>> foreach (split(/:/,$ENV{PATH})) { print "Found $_/rsh\n" if -x "$_/rsh" }


> Splitting PATH on /:/ is wrong. Use $Config{path_sep} instead.


I did say it was a quick way.

To anyone else reading this thread, don't forget you'll need "use Config"
to populate the %Config hash values.

Chris
 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      08-19-2005
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
>
> <>], who wrote in article <5hngt2->:
>>Leon Nabot <nabotleon@hotmail_n0_spamz.com> wrote:
>>>I try to find a quick solution to find onto the PATH where is located an
>>>executable as "which" do.
>>>For the moment the only solution seems to write a module which browse
>>>each directory of the PATH searching the file.

>>A quick way for a single command is:
>>
>> foreach (split(/:/,$ENV{PATH})) { print "Found $_/rsh\n" if -x "$_/rsh" }

>
> Splitting PATH on /:/ is wrong. Use $Config{path_sep} instead.


Or:

use Env '@PATH';


John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Run Unix shell command $ parse command line arguments in python rkoida@yahoo.com Python 4 04-23-2005 04:42 AM
Perl CGI script to emulate a shell command line window Alain Star Perl Misc 7 01-18-2005 03:20 PM
compile C programs with UNIX system calls (= Unix Programs??) jrefactors@hotmail.com C Programming 18 01-10-2005 03:35 AM
compile C programs with UNIX system calls (= Unix Programs??) jrefactors@hotmail.com C++ 12 01-10-2005 03:35 AM



Advertisments