use Benchmark qw/countit cmpthese/; sub run($) { countit(1, @_) } cmpthese { read_proc => run q{ open(WORDS,"words.txt") or die("Wordlist unavaliable.\n"); my @words = ; close(WORDS); foreach $word (@words){ chomp $word; if ($word =~ m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$word); $hitcounter++; } $counter++; } }, for_proc => run q{ open(WORDS,"words.txt") or die("Wordlist unavaliable.\n"); foreach $word (){ chomp $word; if ($word =~ m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$word); $hitcounter++; } $counter++; } close(WORDS); }, while_proc => run q{ open(WORDS,"words.txt") or die("Wordlist unavaliable.\n"); while($word = ){ chomp $word; if ($word =~ m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$word); $hitcounter++; } $counter++; } close(WORDS); } }; #### s/iter for_proc read_proc while_proc for_proc 5983 -- -6% -100% read_proc 5645 6% -- -100% while_proc 2.42 246713% 232775% --