![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Re: Efficienty truncating a long stringby ysth (Canon) |
on Dec 18, 2003 at 16:40 UTC ( #315563=note: print w/replies, xml ) | Need Help?? |
Then you probably want to use 4-arg substr to truncate the buffer and save the fragment all at once:
Note that length($buffer) is bigger than the actual length(buffer)-$end-1 you want, but specifying a length larger than is available is guaranteed to not cause problems; you'll just get what is there. If the buffer ends with "\n", you'll get an empty $fragment.
In Section
Seekers of Perl Wisdom
|
|