Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Testing a string for a range of characters

by Albannach (Monsignor)
on Jan 24, 2001 at 21:12 UTC ( [id://54045]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # predefine $testlist as a simple string of the set of acceptable char
    +acters then
      'index' => sub {
                       $test_char = chr( int( rand 256 ) );
                       if (index($testlist, $test_char) > -1 && length($te
    +st_char)==1) {} else {}
                     },
    
  2. or download this
    Benchmark: timing 10000000 iterations of comp, exist, index, index2, r
    +egex, regex2, regex3...
          comp: 44 wallclock secs (41.64 usr +  0.00 sys = 41.64 CPU) @ 24
    +0147.93/s (n=10000000)
         exist: 41 wallclock secs (38.30 usr +  0.00 sys = 38.30 CPU) @ 26
    +1117.06/s (n=10000000)
    ...
         regex: 55 wallclock secs (53.28 usr +  0.00 sys = 53.28 CPU) @ 18
    +7684.17/s (n=10000000)
        regex2: 53 wallclock secs (52.34 usr +  0.01 sys = 52.36 CPU) @ 19
    +0989.13/s (n=10000000)
        regex3: 53 wallclock secs (50.97 usr +  0.00 sys = 50.97 CPU) @ 19
    +6197.69/s (n=10000000)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://54045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-25 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found