in reply to Re: Seeking the longest string in an array
in thread Seeking the longest string in an array

Change cmp to <=>.

Change /.../ to /\Q...\E/.

Change /.../ to /.../i.

O(N*log(N) + N2*M2). That's a worse worst case than the OP. In practice, though, yours would be faster, because the inner loop will be get much smaller than N very fast.

Replies are listed 'Best First'.
Re^3: Seeking the longest string in an array
by mpeters (Chaplain) on Dec 12, 2004 at 02:41 UTC
    change $data[0] =~ /\Q$_\E/ to index($data[0], $_).

    Should be faster.
      nope, won't work. He's doing case-insensitive searches.
        you're right, I missed that. But even index(lc($data[0]), lc($_)) should be faster than $data[0] =~ /\Q$_\E/i.