while (<>) { ..... if(/...../) { ... } elsif(/...../) { ... } ..... # and a bunch more regexps increment_counters(...); ..... } sub increment_counters { .... if(/...../) { ..... next; # note that this nexts the above loop } if(/..../) { .... next; } ...... } #### if( qr/..../ ) #### my $date = qr/...../; if(m/$date/) { ..... }