in reply to foreach loop bug

It's crashing because the asterix characacters are being interpreted as regular expression characters (when you do $who =~ $i).

With the code you've given it's hard to see what you're trying to do here - so I'm not sure what the correct fix would be.