in reply to match loop failure

Without you showing any input data, actual output data and expected data, it is hard to give specific advice. After neatening up your code with perltidy, one really suspicious line is:
foreach ($line2) {
Since $line2 is a scalar, the foreach loop will only loop (at most) once.

Generic advice:

Replies are listed 'Best First'.
Re^2: match loop failure
by Anonymous Monk on Jun 08, 2011 at 17:23 UTC

    Apologies it was a first post. You were correct about the scalar. Thanks for your help.