in reply to delete lines till

Try this. Although I'm not sure how this relates to your original question.
#!/usr/bin/perl use strict; my @records = <DATA>; for (0 .. $#records) { print $records[$_] . $records[$_ + 1] if ( $records[$_] =~ /\{TT\}/ ); } __DATA__ S 9912290449 00005941^B{TT} D {TAG} 9912290449 {PUBLICATION} THE OS {DATE} 000101 S 9912290450 00005941^B{TT} R {TAG} 9912290450 {DATE} 000101 {TDATE} Saturday, January 1, 2000 S 9912290451 00005941^B{TT} D {TAG} 9912290451 {DATE} 000101 {TDATE} Saturday, January 1, 2000

Replies are listed 'Best First'.
Re^2: delete lines till
by Anonymous Monk on Aug 26, 2009 at 11:55 UTC
    S 9912290449 00005941^B{TT} D S 9912290450 00005941^B{TT} R S 9912290451 00005941^B{TT} D <code/> But I want to print only the statemtents which has 'D' and its above l +ine. Yhe output should be something like this <code> S 9912290449 00005941^B{TT} D S 9912290451 00005941^B{TT} D