On 7/24/06, Craig Cardimon <[EMAIL PROTECTED]> wrote:

> That is, indeed, the rub. Some files are HUGE (large enough to bring the
> system to its knees), and slurping is out of the question -- much to my
> chagrin. To make this script handle ALL cases, I have to pretend all
> files are biggies, and process line-by-line.
>
> Craig

An extremely nifty trick that might be appropriate here is to set $/
to your tag --
either begin or end.  Then instead of having
to work with lf-delimited lines and munge those into records, the
readline function
(a.k.a <>) will give you a whole record.  See perldoc perlvar for details.

It would be nice if $/ could be a regex but it can't (at this time)
so your record separator tag must always be in the same case.  Writing
a input routine that reads a char at a time and returns regex-delimited records
would not be that tough if you really need it; but then there's no
advantage over
what you're currently doing with the flip-flop operator.  Except you
could then handle
a file that doesn't insert a line break between two of the target
elements, which
currently will cause you grief if it appears -- something like </TAG><TAG>


-- 
David L Nicol
you only get one stone per turn
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to