Files
File-DirWalk/examples/find-perl-binary.pl
2013-03-10 18:07:01 +01:00

35 lines
466 B
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
use File::DirWalk;
my $dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
if ($dw->currentBasename() =~ /sbin|lib|share|local|include|libexec|X11/) {
return PRUNE;
}
return SUCCESS;
});
my $found = "";
$dw->onFile(sub {
my ($path) = @_;
if ($dw->currentBasename() eq "perl") {
$found = $path;
return ABORTED;
}
return SUCCESS;
});
$dw->walk("/usr");
print "perl is in $found\n";