http://qs321.pair.com?node_id=221358


in reply to N Permutations of M Items

$_=shift||"ciolnaot"; my $s = join'?',(sort split//),""; while( <> ){ chomp; next unless length == 4; my $t=join'',sort split//; print "$_\n" if $t=~/^$s$/; }