Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Here is what I have right now:
"killed" would be that code chunks "name" (from reference above.)elsif (/..a regex goes here../) { if(ref($self->{_ref_killed}) eq 'CODE'){ $self->{_ref_killed}->($1,$2,$3) } elsif(ref($self->{_ref_killed}) eq 'ARRAY'){ foreach my $sr (@{$self->{_ref_killed}}){$sr->($1,$2,$3)} } elsif(ref($self->{_ref_default}) eq 'CODE'){ $self->{_ref_default}->($1,$2,$3) } $self->_last_death($2); }
As with all log parsing, I'm racing for time. Some benchmarks showed a simple ++ operation with and without eval:
Without Eval: 0.059999942779541 With Eval: 4.15600001811981
So eval is out of the question. As I said above, I'd personally perfer to have a hash of arrays:
If I can make this all a big maintainable hash, that would be far superior to having the same (generally) code repeated over and over.$type{killed} = [$regexref,3]; # 3 to pass $1,$2, and $3 #above is not exact and has problems I'm sure. Just for the idea.
Any ideas? Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Speed vs Laziness
by merlyn (Sage) on Feb 27, 2001 at 07:21 UTC | |
|
Re: Speed vs Laziness
by aardvark (Pilgrim) on Feb 27, 2001 at 07:30 UTC | |
|
Re: Speed vs Laziness
by MeowChow (Vicar) on Feb 27, 2001 at 08:04 UTC |