while ( lines_to_read() ) { if ( the_line_is_the_right_header()) { if ( the_line_also_has_impressions) { # impression things } } } #### while (files_to_read()) { next unless the_line_is_the_right_header(); while ( lines_to_read() ) { next unless the_line_has_impressions(); # impression things last; # no need to look further in this file } }