my $run_start = 0; foreach my $index ( 0 .. @sorted - 2 ) { if ( ! prop_matching( $sorted[$index], $sorted[$index+1] ) ) { output_sets( $run_start, $index ); $run_start = $index + 1; } }