in reply to Help With Parsing a File

Yet another way utilizing $/:
$/="\n--\n"; my $value; while (<>) { my @arr = split "\n"; if (@arr >= 3 and $arr[-3] =~ /ABC SET/) { $value++; } }

Replies are listed 'Best First'.
Re: Re: Help With Parsing a File
by OM_Zen (Scribe) on Jan 18, 2003 at 04:07 UTC
    Hi,

    while(<fname>){ $/="\n--\n"; ($_ =~ /ABC SET/)?$values++:next; }


      Not exactly what the OP was asking for. He wants "ABC SET" on one line, and a line with nothing but "--" two lines below it. Your solution will find "ABC SET" and "--", but we don't know how many lines apart they are. This might work though:
      $/="\n--\n"; while (<FILE>) { $value++, next if /.*?ABC SET.*\n.*\n--\n/; }