[Oc-pm] Chain of subs...
Wyatt Draggoo
wyatt at draggoo.com
Fri Jul 9 12:09:24 CDT 2004
I'm writing a log parser for some things at work, and am trying to figure
out the best way to run each line of the log through a chain of subroutines.
Is an array of sub references the best way to go for this?
Thanks,
Wyatt
Sample, untested code here:
my @parsers = (
\&parser1,
\&parser2,
\&parser3,
\&parser4
)
while (<>) {
foreach my $parseSub (@parsers) {
&$parseSub($_);
}
}
sub parser1 {
# do stuff...
}
...
--
Wyatt Draggoo
More information about the Oc-pm
mailing list