To VSarkiss So you want the line printed if it does not end in "matches)"? That could be as simple as: while () { next unless /matches\)$/; print LOG; } Changing "unless" to "if" is what I'm yabbing about but never mind.