in reply to Re^2: Searching parallel arrays.
in thread Searching parallel arrays.

Not sure why, but I get no output from your code when I use these test data:

my @source_data = ( [ 1, 9, 17 ], [ 2, 10, 18 ], [ 3, 11, 19 ], [ 4, 12, 20 ], );

Replies are listed 'Best First'.
Re^4: Searching parallel arrays.
by jbert (Priest) on Dec 08, 2006 at 16:35 UTC
    Thanks. Looks like there are two bugs. The '1, 2, 3, 4' is being missed because the test in the loop is incorrect (due to my trying to avoid writing the test twice). The loop should be:
    foreach my $number (@sorted_numbers) { push @recent, [ $number, $from_whence{$number} ]; shift @recent if @recent > 4; check_and_handle_contig(\@recent) if @recent == 4; }
    the other sequences are missed because of the numeric sort problem L~R noticed. The sort should be:
    my @sorted_numbers = sort { $a <=> $b } map { @{$_} } @source_data;
    with these changes in, it seems to find them all. Thanks for the test cases :-)