#!/usr/bin/perl # https://perlmonks.org/?node_id=11105638 use strict; use warnings; use Path::Tiny; my @words = grep /^[a-z]{4,}\z/ && /[aeiouy]/, # lc, size & vowel path('/usr/share/dict/words')->lines({chomp => 1}); my @tiles = map +('a' .. 'z')[rand 26], 1 .. 9; print "tiles: @tiles\n"; my @matches; my $pattern = join '', map "$_?", sort @tiles; for my $word ( @words ) { if( join('', sort split //, $word) =~ /^$pattern$/ ) { push @matches, $word; } } print "\nmatches:\n\n@matches\n";