----- Original Message ----

> From: Ovid <publiustemp-perl6interna...@yahoo.com>

> > This patch implements the .trim() method for strings.
> Now that I'm reading S29, I see there is no .trim() method there.  I got that 
> because it was referenced in pugs in the cookbook (not in tests, though) and 
> I 
> was trying to get the examples to run.  Bummer :(

Sorry for constant spamming, but now that I've put disparate pieces together, I 
see what's going on here.  I'll stop soon, but I am *sick* of rewriting the 
trim() function over and over :)

There are no tests because it's not in the spec.  If there's a spec, I know 
where to write the tests and will happily commit tests for them to Pugs and 
I'll submit a new patch against any-str.pir and t/spectest.data to get them to 

http://tinyurl.com/4xjnh, a mailing list thread where Larry wrote:

: (Replying to p6l instead of p6c as requested.) 
: On Mon, Apr 04, 2005 at 10:39:16AM -0700, Larry Wall wrote: 
: > (Now that builtins are just functions out in * space, we can probably 
: > afford to throw a few more convenience functions out there for common 
: > operations like word splitting and whitespace trimming.  (Specific 
: > proposals to p6l please.)) 

So even though it's not in the spec, it seems like something Larry is not 
entirely opposed to (or wasn't back in 2005).  So here's my proposal (copied to 

  =item trim
      our Str multi Str::trim ( Str $string )

  Removes leading and trailing whitespace from a string.


I could optionally make the following work:


Setting leading or trailing to false (they default to true) would result in 
either leading or trailing whitespace not being trimmed.  Setting both to false 
would be a no-op.

Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to