Advertisement
Guest User

Untitled

a guest
Oct 12th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.44 KB | None | 0 0
  1. #!/usr/bin/env perl6
  2.  
  3. use v6;
  4.  
  5. use File::Find;
  6.  
  7. sub MAIN(Str :$pattern = '')
  8. {
  9.     my $files = find(:dir('.'), :type('file'));
  10.     say "Found {@$files.elems} file(s) before filtering";
  11.     my Int $matches = 0;
  12.  
  13.     if $pattern eq ''
  14.     {
  15.         say "All files are matching";
  16.         return;
  17.     }
  18.     for @$files -> $file
  19.     {
  20.         if $file ~~ /$pattern/
  21.         {
  22.             say "Match: {$file}";
  23.             $matches++;
  24.         }
  25.     }
  26.  
  27.     say "Found {$matches} matches for /{$pattern}/";
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement