#!/usr/bin/perl -lw use strict; while( ) { chomp; if( ! m[TIMINGCHECK] ) { print; next; } my $count= tr[(][(] - tr[)][)]; do { s[^][//]; print; last # Leaves the while( ) loop if ! defined( $_= ); chomp; $count += tr[(][(] - tr[)][)]; } while( 0 <= $count ); print; }