use strict; use warnings; my $str=""; for $str('aaa'..'ccc') { if($str=~m/^[abc]{3}$/) { if($str!~m/(.*a.*a)/) { if($str!~m/(.*b.*b)/) { if($str!~m/(.*c.*c)/) { print "\' $str \' is a Match\n"; } else { print "The string $str contains duplicated 'c'\n"; } } else { print "The string $str contains duplicated 'b'\n"; } } else { print "The string $str contains duplicated 'a'\n"; } } else { print "Either the string \'$str\' contains a character not belonging to the class [abc] or is more than 3 characters\n"; } } #### use strict; use warnings; my $str=""; for $str('aaa'..'ccc') { if($str=~m/^[abc]{3}$/ && $str!~m/(.*a.*a)/ && $str !~ m/(.*b.*b)/ && $str!~ m/(.*c.*c)/) { print "\' $str \' is a Match\n"; } }