----- Original Message ----
> From: Nicholas Clark <n...@ccl4.org>
> You can also write that as a single substitution, although it turns
> out the combined statement is slower than the separate ones. That
> might not matter to you, though.
> If there's one answer that is both elegant and fast, there is no longer a
> compromise needed, nor do journeymen programmers waste time questing for a
> better answer that masters know does not exist.*
You know, I rewrote .trim as:
.sub 'trim' :method :multi(_)
.local string s
s = self
s = 'trim_start'(s)
s = 'trim_end'(s)
I thought about the performance issue but opted for correctness and "no
duplicate code". I figured it's trivial to speed up later, if need be.
Short of trying to figure out how to survey the CPAN and see what people are
really doing with strings, I'm unsure of how to solve the "useful/baggage"
dichotomy. Maybe just going through and turning the Perl 5 Cookbook into a
series of builtins ... :)
(Note that the latter suggestion was a joke. Mostly)
I'd still opt for removing .chop, though. I think only once have I ever seen
it used appropriately. All other times the user wanted .chomp.