in reply to trouble matching
Examine the contents of $line and $term with a debugger, or print their contents like this:
print "line >$line<, term >$term<\n"; [download]