in reply to Re: some forking help
in thread some forking help
hmm.. I smell a chance to test my understanding. Creating and storing qr// expressions takes extra work, but beats this simpler form:
my %hash_one = { 'string_one' => 0, 'string_two' => 0, 'string_three' => 0, }; @ARGV = qw(file.txt); close ARGV; while (<>) { for $key (keys %hash_one) { $hash_one{ $key }++ if (/$key/); } }
because qr// lets perl precompile the regexp. That would pay off in cases like this, where we'll be looping through the same set of regexps over and over again, yes?
|
|---|