So, first off, this is for a homework assignment. The problem involves taking an arbitrarily long list of REGEX strings and searching for them in a file. Would it be better, or faster, to search each line in the file, one string at a time or with alternation...(str1|str2).
my $rexs = '(' . join('|', @regexs) . ')'; #... if(/$rexs/) {...} #or.. foreach $rex (@regexs) { if(/$rex/) {...} }
In reply to Alternation vs. looping for multiple searches. by kprice++
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |