in reply to How to do pattern matching and output the results?

You might want to try:
print join("\n",grep {/$a/i} @lines);
to print any lines containing $a.
And change
@lines=$a   # this should be an error if you use warnings.
to
@lines=<INFO>; close INFO;

Originally posted as a Categorized Answer.