| Hendrik Visage on Thu, 20 Feb 2003 15:38:49 +0200 (SAST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| [Linux dev] Re: Perl and matching several regex's |
On Thu, Feb 20, 2003 at 03:22:23PM +0200, Oskar Pearson wrote:
> I normally do something like this:
> if ($_ =~ /somepattern/) {
> &processsomepattern($_);
> } else if ($_ =~ /otherpattern/) {
> &processotherpattern($_);
> } else {
> die("Unable to interpret line $lc");
> }
I was more thinking in terms of (but not perl syntactically correct yet)
for $i in keys %RegexHash
{
if ($_ =~ $RegexHash[$i])
then
&process($i,$_);
break
fi
}
> Then I try and order the if statements in a way which
> is going to be the most efficient in terms of the number
> of likely matches.
The matches are of equal likenes. It's Radius Accounting log
records.
Hendrik