if($ModNameList =~ m/$name/g) {
You are using the /g global option in scalar context so the regular expression keeps track of the current position in the string for the next match thereby bypassing matches that are to the left of the current match.
None of the patterns in your example require the use of the /g option.
In reply to Re: Pattern Matching Failing
by jwkrahn
in thread Pattern Matching Failing
by upallnight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |