in reply to print matching lines

Sorry, but your question doesn't make sense. Should it print # input 1 if any of the other inputs have the same string on line 3? Because in that case you might switch the whole thing around and just look for unique occurences of line 3 and print everything else. Please provide some more information on what you want exactly as well as some code you've already tried.
update to prevent the question thread going 16 levels deep: how about something like: (untested code alert)
use strict; use warnings; my $FH = *insert your filehandle stuff here*; my $linecounter = 0; my $headerline; while(my $line = <$FH>) { chomp($line); #not sure if needed... unless(my $modulo = ($linecounter % 4)) { $headerline = $line; } elsif(($modulo == 3) && ($line eq 'ord')) { print "$headerline\n"; } $linecounter += 1; }


Remember rule one...

Replies are listed 'Best First'.
Re^2: print matching lines
by Anonymous Monk on Jul 10, 2005 at 19:41 UTC
    if the 4ith line matches ord it should print the # input line
      so are you looking for a match between # input 1 and another one? or between any 2 inputs? and, another important question, are all the inputs numerically ordered like that?


      Remember rule one...
        this is some code i have tried
        while (<FH>) { local $/ = '# input'; if (m/1ord/) { print $/, $_; } }
        the # input line is not numerically ordered (just to illustrate). so the only match is for the line ord. if it does match then print the # input three lines above