in reply to Testing a string for a range of characters

It might also pay to ask yourself, "How many times will this test be repeated?" If it's just once, I might suggest that you move your hash creation into your benchmark test, as I suspect the expense involved in the construction of the hash will make the other methods a bit more appealing. If your test will be repeated dozens or more times on the same range, a hash is clearly the better way to approach it.
  • Comment on Re: Testing a string for a range of characters

Replies are listed 'Best First'.
Re: Re: Testing a string for a range of characters
by BoredByPolitics (Scribe) on Jan 24, 2001 at 20:25 UTC
    The test will be repeated possibly thousands of times, as records are read in from an array, but I agree, if it was only going to be a one off, then I'd probably have left it as a regex.

    Pete

      If you're reading these in from an array, I wonder if a test like this might be faster:
      my @array = get_block_of_data; data_is_bad if join("", @array) =~ /[^A-Z]/;