'*.p[lm]'.glob.each { |file| say file } # Perl files under this directory
func file_match(Block callback, pattern=/\.txt\z/, path=Dir.cwd) {
path.open(\var dir_h) || return nil
dir_h.entries.each { |entry|
if (entry.basename ~~ pattern) {
callback(entry)
}
}
}
file_match(
path: %d'/tmp',
pattern: /\.p[lm]\z/i,
callback: { |file|
say file;
}
)