sub no_dups { my $in = join( '', sort split '', shift ); ( my $out = $in ) =~ y/smtwhfa/smtwhfa/s; $out =~ y/smtwhfa//cd; print "no dupes $in\n" if length $in == length $out; } no_dups( 'afhwtms' ); no_dups( 'smtthfa' ); no_dups( 'smatwhfa' ); no_dups( 'afhwtmsz' );