Hi,
please see my benchmark test
use strict;
use Benchmark qw(cmpthese);
# A big, sorted list (475254 elements)
my @list = ('a'..'zzzz');
##Put the list into a string
my $string = join(/ /, @list);
$string .= "\n";
cmpthese(0, {
# Looking for a random item in @list with grep
index => sub {
# A random element in the list
my $pattern = 'fqsu fqsv fqsw fqsx fqsy';
my $result = index($string, $pattern);
},
# Looking for a random item in @list linearly (with foreach)
regex => sub {
my $pattern = 'fqsu fqsv fqsw fqsx fqsy';
$string =~ /$pattern/;
},
}
);
I also did another test where I read a proper HTML file and received similar results. Can you please tell me what you did different?
Everybody seems to think I'm lazy
I don't mind, I think they're crazy