Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created July 13, 2017 15:51
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 zoffixznet/1203c8a3b93421bdd79fa3beaa57684c to your computer and use it in GitHub Desktop.
Save zoffixznet/1203c8a3b93421bdd79fa3beaa57684c to your computer and use it in GitHub Desktop.
class PortUtils::Search {
constant PORTS = '/usr/ports/';
has IO::Path @!cats = PORTS.IO.dir.map: |*.dir.grep: *.d;
method name(Str $query) {
my @matches = @!cats.grep: *.basename.contains: $query;
say “There are {+@matches} ports with names matching "$query":”;
.relative(PORTS).put for @matches;
}
}
PortUtils::Search.new.name: 'perl';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment