in reply to Re^8: Benchmarking "Are all these characters in this sentence?" (Are you bored yet? :)
in thread Benchmarking "Are all these characters in this sentence?"

Actually, it's your tests that are broken. They assume that the routines will return "0" for false, where as my routines (all of them including buk3 which you said passes all the tests), return undef. And that is where the Use of uninitialized value in numeric eq (==) ... warning message is coming from. Your tests (or test tools) not my code.

The received wisdom is that subs should just return; to indicate false as this will do the right thing when called in both scalar and list contexts.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re^9: Benchmarking "Are all these characters in this sentence?" (Broken tests, not code!)
  • Select or Download Code

Replies are listed 'Best First'.
Re^10: Benchmarking "Are all these characters in this sentence?" (Broken tests, not code!)
by RMGir (Prior) on Sep 02, 2008 at 11:16 UTC
    Fixed with a !!, thanks.

    No, that didn't do it. I'm getting undef where a true return is expected...

    Ah, I see. You had -1 ==, I think you meant -1 !=...

    buk4 => sub { ( -1 != index $_[0], chop $_[ 1 ] ) || return for 1 .. length +$_[ 1 ]; 1; },
    Once I made that change, it passes all the tests (which are now updated to check truth values) and it does win the speed crown by a 1% (on Short) to 11% (on LongLong) margin over buk3 (on perl 5.8.4 - I don't have my mac handy).

    Mike