#!/usr/bin/perl
#  -*-coding:latin-1;-*-  «sburke»   Time-stamp: "2005-09-27 16:59:09 ADT"  µ
use constant DEBUG => 0;
use strict;
use warnings;

# Lists everything executable in your $PATH

my @path = grep m/\S/, split ':', $ENV{'PATH'} || die "No path!?";

my %seen;
my %x;
foreach my $p (@path) {
  next if $seen{$p};
  $seen{$p} = 1;

  opendir(D, $p) or next;

  DEBUG and print "Reading $p\n";

  while(defined($_ = readdir(D))) {
    next if $_ eq '.' or $_ eq '..' or m/~/;
    $x{ $_ }++ if -e "$p/$_" and -x _ and -r _ and -f _;
  }
  closedir(D);
}

print map "$_\n", sort keys %x;

__END__
