Get list of files matching a pattern

Author: stmuk

You want a list of filenames matching a pattern

Source code: 09-06-filenames-matching-pattern.p6

#!/usr/bin/env perl6

use v6;

sub MAIN(:$dir = ".") {
    my @perl-files = dir $dir, test => /\.pl/;

    #  returns a list of IO::Path objects

    for @perl-files.sort -> $io {
        say $io.basename;
    }
}