in reply to foreach loop bug

There is no particular reason that should "crash". What you are likely running into is that you haven't properly escaped the regex-special sequences and characters like asterisks. Try making the simple change of instead of $who =~ $i write $who =~ /\Q$i/ which will escape the asterisks from 'abc2000@*****' to 'abc2000\@\*\*\*\*\*' automatically. See also "quotemeta" in perlop.