Created
June 16, 2012 19:03
-
-
Save gerdr/2942255 to your computer and use it in GitHub Desktop.
recursive directory walking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub dirwalk(Str $dir = '.', Mu :$d = none(<. ..>), Mu :$f = *, | |
:&dx = -> $ {}, :&fx = -> $ {}) { | |
for dir($dir, :test(*)) { | |
given "$dir/$_".IO but $_ { | |
when .f { | |
&fx.(.path) if $f.ACCEPTS($_) | |
} | |
when .d { | |
dirwalk(.path, :$d, :$f, :&dx, :&fx) if $d.ACCEPTS($_) | |
} | |
} | |
} | |
&dx.($dir); | |
} | |
my @modules = gather <lib lib6>.grep(*.IO.d).map({ | |
dirwalk($_, :f(/\.pm6?$/), :fx(&take)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment