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.
In reply to Re: problem with a regex loop
by toolic
in thread problem with a regex loop
by grashoper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |