Skip to content

Instantly share code, notes, and snippets.

@moritz
Created June 29, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/3020637 to your computer and use it in GitHub Desktop.
Save moritz/3020637 to your computer and use it in GitHub Desktop.
File::Find patch
diff --git a/lib/File/Find.pm b/lib/File/Find.pm
index c649980..9986078 100644
--- a/lib/File/Find.pm
+++ b/lib/File/Find.pm
@@ -44,13 +44,9 @@ sub checkrules ($elem, %opts) {
return True
}
-sub file-from-path($path) {
- $path.split('/')[*-1];
-}
-
sub find (:$dir!, :$name, :$type) is export {
my @targets = dir($dir).map: {
- File::Find::Result.new(dir => $dir, name => file-from-path(.path));
+ File::Find::Result.new(dir => $dir, name => .basename);
};
my $list = gather while @targets {
my $elem = @targets.shift;
@@ -58,7 +54,7 @@ sub find (:$dir!, :$name, :$type) is export {
if $elem.IO ~~ :d {
for dir($elem) -> $file {
@targets.push(
- File::Find::Result.new(dir => $elem, name => file-from-path($file.path))
+ File::Find::Result.new(dir => $elem, name => $file.basename)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment