Are the elements of @commands supposed to be patterns? Or do you want exact matches (use eq)? Or perhaps check for a substring (use index)? Because if you want to do either of them, and one or more of the commands contain something that is special to the regexp engine (parens, *, +, etc), it isn't going to work.