The which in Perl discussion made me think about all the stuff in my PATH. So I decided to find if I have any conflicts in my PATH...

In case you were wondering, it turned out I had /usr/bin in my PATH twice :-(

#!/usr/bin/perl -w use strict; my %locations; foreach my $path (split(/:/,$ENV{PATH})) { opendir(DIR,$path) || die "Directory $path in your PATH can not be opened:$!\n"; foreach my $file (readdir(DIR)) { next if -d "$path/$file"; # not sure if this is really needed... next unless -x _; push (@{$locations{$file}},$path); } } foreach my $file (sort keys %locations) { print "$file :",join(" ",@{$locations{$file}}),"\n" if scalar($#{$locations{$file}}); }

Replies are listed 'Best First'.
•Re: Conflicts in my PATH
by merlyn (Sage) on Mar 05, 2004 at 23:27 UTC
      Ouch :-(

      I was aware of your archive, and have perused it on various occasions, but I never systematicaly read through all the articles. And when the problem occured to me I didn't remember your solution. In fact, I still don't remember if I had seen it before or not.

      I'm glad your solution is so much better that you can't possibly accuse me of plagiarism :-) :-)

use Env qw( @PATH );
by PodMaster (Abbot) on Mar 05, 2004 at 22:06 UTC
    Its cross platform   portable :)
    E:\>perl -MEnv=@PATH -le"print for @PATH" e:\sybase\ODBC e:\sybase\ASEP_Win32 e:\sybase\OCS-12_5\dll e:\sybase\OCS-12_5\lib3p e:\sybase\OCS-12_5\bin E:\WINNT\system32 E:\WINNT E:\WINNT\System32\Wbem C:\perl\bin\ E:\Program Files\ATI Technologies\ATI Control Panel ...

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Conflicts in my PATH
by ambrus (Abbot) on Mar 06, 2004 at 19:39 UTC

    I have tidied my PATH by hand before. You may want to check MANPATH too, that can have non-existant or duplicate directories too (depending on your distrib of course).

    Update: Also you may want to check that /usr/local/bin is before /usr/bin and /bin, I had a problem with that once (that was because I set them up wrong actually).