On Thu, 1 Jul 2004, Juerd wrote: > Matt Diephouse skribis 2004-06-30 20:51 (-0400): > > my $string = "Hello, World!"; > > say $string[0..4]; # prints "Hello\n" > > $string[7...] = "Larry!"; > > say $string; # prints "Hello, Larry!\n" > > And that "array" is one of bytes? graphemes? > > In general, I like the idea. In <[EMAIL PROTECTED]>, almost > the same was suggested, but implemented differently: a string's .bytes > method in list context (but isn't it array context, technically?) would > dwym. As would the other parts-of-string methods.
What if you could add the slice onto the method: my $string = "Hello, World!"; say $string.bytes[0..4]; # prints "Hello\n" $string.codepoints[7...] = "Søren!"; say $string; # prints "Hello, Søren!\n" The string slicing operator would have to return an array of bytes/codepoints/etc in list context and a substr in scalar context. ~ John Williams