in reply to delete lines till

Deal with records, not lines.
local $/ = ''; while (<>) { next if /\A.*\nD$/m; print; }
More readable, more versatile:
local $/ = ''; while (<>) { chomp( my @rec = split /^/m ); my $hdr1 = shift(@rec); my $hdr2 = shift(@rec); my %rec = @rec; next if $hdr2 eq 'D'; print; }

Replies are listed 'Best First'.
Re^2: delete lines till
by Anonymous Monk on Aug 25, 2009 at 06:38 UTC
    Please tell me what does the line mean? /\A.*\nD$/m;. How to store that records with 'D' to a variable?
      Why don't you install YAPE::Regex::Explain?
      The regular expression: (?m-isx:\A.*\nD$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?m-isx: group, but do not capture (with ^ and $ matching start and end of line) (case- sensitive) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \A the beginning of the string ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \n '\n' (newline) ---------------------------------------------------------------------- D 'D' ---------------------------------------------------------------------- $ before an optional \n, and the end of a "line" ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------