M: Fixed example code.
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use File::Basename;
|
|
||||||
use File::DirWalk;
|
use File::DirWalk;
|
||||||
|
|
||||||
my $dw = new File::DirWalk();
|
my $dw = new File::DirWalk();
|
||||||
@@ -11,21 +10,20 @@ my $dw = new File::DirWalk();
|
|||||||
$dw->onDirEnter(sub {
|
$dw->onDirEnter(sub {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
|
||||||
print "$path\n";
|
if ($dw->currentBasename() =~ /sbin|lib|share|local|include|libexec|X11/) {
|
||||||
|
|
||||||
if (basename($path) =~ /sbin|lib|share|local|include|libexec|X11/) {
|
|
||||||
return PRUNE;
|
return PRUNE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
my $found = "";
|
||||||
|
|
||||||
$dw->onFile(sub {
|
$dw->onFile(sub {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
|
||||||
print "$path\n";
|
if ($dw->currentBasename() eq "perl") {
|
||||||
|
$found = $path;
|
||||||
if (basename($path) eq "perl") {
|
|
||||||
return ABORTED;
|
return ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,3 +31,5 @@ $dw->onFile(sub {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$dw->walk("/usr");
|
$dw->walk("/usr");
|
||||||
|
|
||||||
|
print "perl is in $found\n";
|
||||||
Reference in New Issue
Block a user