in reply to Can PERL know a line without matching?

It is somewhat difficult to understand from your problem statement, so I'll make a few general observations and hope you can take them and run, or clarify.

First, you could indicate what part of the file you are in with a flag, ie,

$meaningless=0; $alternate=0; while (<FILE>) { if (/MEANINGLESS/) { $meaningless=1; $alternate=0; } elsif (/ALTERNATE/) { $meaningless=0; $alternate=1; } }

Next, I am not at all clear on why you need line numbers. A match is a match is a match. If it matches, you can print it, regardless of the line number. You can count line numbers if you combine with the above flag system:

$meaningless_count=0; $alternate_count=0; while (<FILE>) { #include flags from above if ($meaningless) { $meaningless_count++; } elsif($alternate) { $alternate_count++; } }
Does any of this help?

Scott