sub naive_sequence_matcher {
    my ( $big, $sub ) = @_; # The big array and the small one.

    use integer;

    my $big_len = @$big; # changed from naive_string_matcher
    my $sub_len = @$sub; # changed from naive_string_matcher

    return -1 if $big_len < $sub_len; # No way.

    my ( $i, $j, $match_j );
    my $last_i = $big_len - $sub_len;
    my $last_j = $sub_len - 1;

    for ( $i = 0; $i <= $last_i; $i++ ) {
        for ( $j = 0, $match_j = -1;
              $j < $sub_len &&
              # changed from naive_string_matcher
              $sub->[ $j ] eq $big->[ $i + $j ];
             $j++ ) {
           $match_j = $j;
        }
        return $i if $match_j == $last_j; # A match.
    }

    return -1; # A mismatch.
}

@a = qw(ab cde fg hij);
@b = qw(cde fgh);
print naive_sequence_matcher( \@a, \@b ), " ",
      naive_sequence_matcher( \@a, [ qw(cde fg) ] ), "\n";
