#!/usr/bin/perl
$vowels = 'aeiouy';
$cons = 'cbdfghjklmnpqrstvwxzy';
%map = (C => $cons, V => $vowels); # init map for C and V
for $class ($vowels, $cons) { # now for each type
for (split //, $class) { # get each letter of that type
$map{$_} .= $class; # and map the letter back to the type
}
}
for $char (split //, shift) { # for each letter in template word
$pat .= "[$map{$char}]"; # add appropriate character class
}
$re = qr/^${pat}$/i; # compile the pattern
print "REGEX is $re\n"; # debugging output
@ARGV = ('/usr/share/dict/words') # pick a default dictionary
if -t && !@ARGV;
while (<>) { # and now blaze through the input
print if /$re/; # printing any line that matches
}