So I'm in the beginning stages of learning perl. I was giyen a set of different rules that a string could have. But, my output is either the first rule or "No conditions are met(the last one) The rules are self-explanatory in my print statements. Here's what I typed up:

print "Input a string"; $string = <>; if($string == /[3579][02468]/) { print "$string is an odd digit followed by an even digit"; } elsif($string == /[a-zA-Z][^a-zA-Z][0-9]/) { print "$string is a letter followed by a non-letter followed by a number"; } elsif($string == /\b[A-Z]/) { print "$string is a word that starts with an uppercase letter"; } elsif($string == /\b[Yy][Ee][Ss]\b/) { print "$string is the word yes in any combination of uppercase and lowercase letters"; } elsif($string == /(\bthe\b)+/) { print "$string is the word with one or more times of 'the'"; } elsif($string == /\d\d?\.\d\d?\.\d\d/ ) { print"$string is a date in the form of one or two digits, a dot, one or 2 digits, a dot, two digits"; } elsif($string == /[\!:;"',\.\?`]/) { print "$string is a puncuation mark"; } else { print "No conditions are met for $string"; }

if($string == /[3579][02468]/) { print "$string is an odd digit followed by an even digit"; }

1. If your string is 12, it will not match because you don't have 1 in your first character class;

2. If you get a match, this does not mean at all that "$string is an odd digit followed by an even digit", it means that "$string contains, somewhere, an odd digit (but not 1) followed by an even digit", so that 'foo36bar}%"&\' will match your regex. Of course, the same remark can be made about the other matches in you code.

Otherwise, please tell us what strings fall into the default "no conditions" message, as I am fairly sure that 'A_7', for excample, should match your second regex (and not the first one).