in reply to advice with Parse::RecDescent
to inch along the string. If $text is small, this is a reasonable way to do it. If $text is large, however, you get a performance hit as you constantly shift the text down in memory.$text =~ s/^$MATCH//;
I'm told that the next version will walk through the string by maintaining pos (using \G and m//g instead), and that this speeds the process up substantially for large strings. Until then, it helps if you can "predigest" the input stream into logical chunks, and hand each one to a separate invocation of a specific grammar step.
In your particular case, if you could limit the invocation to separately invoking P::RD methods for header, then each separate record, then trailer, you'd be much speedier.
You could keep it within one invocation of P::RD by pre-digesting your file into a @queue, then putting just the header into $text, calling the top-level rule, and having the rule for the header suck the next item with $text .= shift @queue, ditto with the rules for record. Of course, backing up would be expensive, but your grammar can commit forward nicely.
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: advice with Parse::RecDescent
by demerphq (Chancellor) on Dec 10, 2001 at 20:24 UTC | |
|
Re: Re: advice with Parse::RecDescent
by demerphq (Chancellor) on Dec 10, 2001 at 21:36 UTC |