![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Efficienty truncating a long stringby dino (Sexton) |
on Dec 18, 2003 at 10:28 UTC ( #315485=note: print w/replies, xml ) | Need Help?? |
It was originally part of a log reader. I found that reading in blocks and working pattern matching on those blocks was much more efficient than on line by line. Obviously you can get partial lines, so I rindex the last /n, save the fragment at the end for the next pass and return the main block truncated. It works like a charm. I was reinventing it and seing how I could make it more efficient.
In Section
Seekers of Perl Wisdom
|
|