in reply to Can PERL know a line without matching?
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:
Does any of this help?$meaningless_count=0; $alternate_count=0; while (<FILE>) { #include flags from above if ($meaningless) { $meaningless_count++; } elsif($alternate) { $alternate_count++; } }
Scott
|
|---|