help needed...

Guys,

There is a file where there are 1000s of records.
In the file if some condition satisfies in a certain TAB record (TAB would be first 3 digits of a certain record) then move TAB and all the records (or lines) after TAB to new_file, until another TAB record is encountered in the same file. (Where the condition will be again checked)

How about some Perl?

my $printit=0;

open( OUTFILE, ">outfile.txt" ) or die( "Failed to open OUTFILE.\n" );

while ( <> )
{
    if ( /^TAB/ )
    {
        $printit = $printit^1;
    }
    if ( $printit )
    {
        print OUTFILE $_;
    }
}

close( OUTFILE ) or die( "Failed to close OUTFILE.\n" );