in reply to problem with a regex loop

You may need to chomp your input lines to remove the newline (\n).
chomp @lines;

You may not want to use the /g modifier on your regex.

Other coding style issues:

In order to avoid a common operator precedence issue, you should use or instead of || in your open statement as Sidhekin previously pointed out.

Adding whitespace to your code, in the form of indentation and around operators, would improve its readability.