Does removing the $ at the end of your regexp fix the problem? I'm assuming that given the content of the file you are parsing you are running this script in windows? Is there a
\r character at the end of the line? Hint try
chop($item) does it remove the
]? if not then you definately have some characters hanging around after the ] that you can't see...Droping the anchor all together will give you the most flexibility as long as the text
[**REQUIRES USER CONTEXT**] can never show up anywhere but at the end.