#!/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; } #### #!/usr/bin/perl -lw use strict; my $count= -1; while( ) { chomp; $count= 0 if m[TIMINGCHECK]; $count += tr[(][(] - tr[)][)] if 0 <= $count; s[^][//] if 0 <= $count; print; }