in reply to print matching lines

You said each entity in the file is composed of 4 lines but the second one in your example only has 3 lines..

Do you have code/thoughts you've tried so far?

one method would be to read 4 lines at a time. if the 4th line matches, print the first line. Another method would be to set $/ to '# input' and then regex the resulting 'lines' (or grep all of them).

Replies are listed 'Best First'.
Re^2: print matching lines
by Anonymous Monk on Jul 10, 2005 at 19:23 UTC
    sorry yes, # input 2 xxx yyyy 1 so with $/ set to # input it would be possible to do a pattern search and print the match?
      yes, that's why i suggested it .. I would (you ignored my questioned about providing code, so i'll continue just guiding with pesudo code until you have something to work from) set $/, then loop through the 'lines' (which will contain multiple \n newlines). During this loop, split on newline to get your array of 4 lines. Note the first one will be just a number (the remainder of the '# input 3' line) and the last one will be '# input ' ($/).
        while (<FH>) { local $/ = '# input'; if (m/1ord/) { print "$/\n";} }
        this prints the local variable, how can i adjust it to print the enitre # input line?