in reply to Re: Re: Re: Re: Bulk Regex?
in thread Bulk Regex?

Ouch.

How many prefixes of each length, though? If you have many of a given length, maybe you could do something like this (writing support code to generate this HOH, of course):

my %prefixList=( 3 => {DEF=>1, SRC=>1}, 6 => {ABCD12=>1}, 10 => {DEEEE11223}, ); #.... # inside the loop foreach my $length(%prefixList) { if($prefixList{$length}->{substr($fields[7],0,$length)}){ ### code here last; } }
If the set of sizes isn't dynamic, you could make that an AOH, with some possibly empty hashes, I guess... You could also get rid of the loop and inline the check for each length, but I don't think that would save you much.

If you're only ever going to have 1 or 2 prefixes of a given length, then this isn't worth it. But given your initial description, I think with a LOT of prefixes and very few different lengths, this could start to pull ahead of the regex.
--
Mike