From 0d51c0eae05e7404690a8c803b91c4368668a503 Mon Sep 17 00:00:00 2001 From: Jens Luedicke Date: Sun, 10 Mar 2013 18:07:01 +0100 Subject: [PATCH] M: Fixed example code. --- examples/find-perl-binary.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/find-perl-binary.pl b/examples/find-perl-binary.pl index 2763aba..85a6f9b 100755 --- a/examples/find-perl-binary.pl +++ b/examples/find-perl-binary.pl @@ -3,7 +3,6 @@ use strict; use warnings; -use File::Basename; use File::DirWalk; my $dw = new File::DirWalk(); @@ -11,21 +10,20 @@ my $dw = new File::DirWalk(); $dw->onDirEnter(sub { my ($path) = @_; - print "$path\n"; - - if (basename($path) =~ /sbin|lib|share|local|include|libexec|X11/) { + if ($dw->currentBasename() =~ /sbin|lib|share|local|include|libexec|X11/) { return PRUNE; } return SUCCESS; }); +my $found = ""; + $dw->onFile(sub { my ($path) = @_; - print "$path\n"; - - if (basename($path) eq "perl") { + if ($dw->currentBasename() eq "perl") { + $found = $path; return ABORTED; } @@ -33,3 +31,5 @@ $dw->onFile(sub { }); $dw->walk("/usr"); + +print "perl is in $found\n"; \ No newline at end of file