my %max =( A=>8, B=>2, C=>5, D=>8, E=>7, F=>1, G=>3, H=>9, I=>8, K=>1, L=>9, M=>1, N=>12, O=>13, P=>1, Q=>0, R=>5, S=>6, T=>4, U=>6, V=>0, W=>1, X=>1, Y=>0, Z=>0); my @n = qw(Affenpinscher AfghanHound AiredaleTerrier Akita AlaskanMalamute AmericanEnglishCoonhound AmericanEskimoDog AmericanFoxhound Basenji BassetHound Beagle BeardedCollie Beauceron BlackandTanCoonhound Bloodhound BluetickCoonhound BorderCollie BorderTerrier Borzoi BostonTerrier BouvierdesFlandres Boxer BoykinSpaniel Briard Brittany BrusselsGriffon BullTerrier Bulldog Bullmastiff ChesapeakeBayRetriever Chihuahua ChineseCrested ChineseShar-Pei Chinook ChowChow ClumberSpaniel CockerSpaniel Collie Curly-CoatedRetriever Dachshund Dalmatian DandieDinmontTerrier DobermanPinscher DoguedeBordeaux EnglishCockerSpaniel EnglishFoxhound EnglishSetter EnglishSpringerSpaniel GermanPinscher GermanShepherdDog GermanShorthairedPointer GermanWirehairedPointer GiantSchnauzer GlenofImaalTerrier GoldenRetriever GordonSetter GreatDane Greyhound Harrier IbizanHound IcelandicSheepdog IrishSetter IrishTerrier Kuvasz LabradorRetriever LakelandTerrier LhasaApso Lowchen Maltese ManchesterTerrier Mastiff MiniatureBullTerrier MiniaturePinscher MiniatureSchnauzer NeapolitanMastiff Newfoundland NorfolkTerrier Pekingese PembrokeWelshCorgi PharaohHound Plott PortugueseWaterDog Pug Puli PyreneanShepherd RatTerrier ShibaInu ShihTzu SiberianHusky SilkyTerrier SkyeTerrier SmoothFoxTerrier SoftCoatedWheatenTerrier SpinoneItaliano St.Bernard StaffordshireBullTerrier WireFoxTerrier WirehairedPointingGriffon Xoloitzcuintli YorkshireTerrier); WORD: for my $word (@n) { my %count=%max; for $c ( split //, uc($word) ) { next WORD if $count{$c}-- <=0; } print "$word\n"; }