#!/usr/local/bin/perl -w
# Schmalspurfassung von ``find'', bei der ein Dateiname
# rekursiv ab dem aktuellen Verzeichnis gesucht wird.
$wanted = $ARGV[0]; # gesuchter Dateiname
find(".", $wanted); # im aktuellen Verzeichnis starten
sub subdirs { # liefere alle Unterverzeichnisse zurueck
my ($path) = @_;
my ($file, @dirs) = ();
return () unless opendir(DIR, $path);
while (defined($file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
push(@dirs, "$path/$file") if -d "$path/$file";
}
closedir(DIR);
return @dirs;
}
sub find {
my ($path, $wanted) = @_;
print "$path/$wanted\n" if -f "$path/$wanted";
foreach $dir (subdirs($path)) {
find($dir, $wanted);
}
}
|