use strict; my %tran_types; foreach ('A'..'Z') { $tran_types{$_} = "" }; my $test_char; timethese(10000000, { 'regex' => sub { $test_char = chr( int( rand 256 ) ); if ($test_char =~ /^[A..Z]$/) {} else {} }, 'comp' => sub { $test_char = chr( int( rand 256 ) ); if (($test_char ge "A") && ($test_char le "Z")) {} else {} }, 'exist' => sub { $test_char = chr( int( rand 256 ) ); if (exists $tran_types{$test_char}) {} else {} }, }); #### Benchmark: timing 10000000 iterations of comp, exist, regex... comp: 56 wallclock secs (55.39 usr + 0.00 sys = 55.39 CPU) exist: 50 wallclock secs (49.34 usr + 0.00 sys = 49.34 CPU) regex: 79 wallclock secs (79.32 usr + 0.00 sys = 79.32 CPU)