tr doesn't take character classes in square brackets ([]), so your code can also be written as:
if (0 == $s =~ tr/IOSM//c) {
Your code counts whether there is any of the letters I, O, S or M in the string. Which is obviously true.
Maybe you wanted to match the letters in order?
m/I+O+S+M+/
In reply to Re: Pattern matching regex problem
by Corion
in thread Pattern matching regex problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |