Returns a Buf which represents the original string in the given encoding and normal form. The actual return type is as specific as possible, so $str.encode('UTF-8') returns a utf8 object, $str.encode('ISO-8859-1') a buf8.

String increment is "magical". It searches for the last alphanumeric sequence that is not preceded by a dot, and increments it.

'12.34'.succ# 13.34'img001.png'.succ# img002.png

The actual incrementation step works by mapping the last alphanumeric character to a character range it belongs to, and choosing the next character in that range, carrying to the previous letter on overflow.

'aa'.succ# ab'az'.succ# ba'109'.succ# 110'α'.succ# β'a9'.succ# b0

String increment is Unicode-aware, and generally works for scripts where a character can be uniquely classified as belonging to one range of characters.

Remove leading and trailing whitespace. It can be use both as a method on strings and as a function. When used as a method it will return the trimmed string. In order to do in-place trimming, once needs to write .=trim

Coerces the invocant to Str, and filters each word that smart-matches against $where through the &filter. With the default filter (first character to upper case, rest to lower) and matcher (which accepts everything), this title-cases each word:

say"perl 6 programming".wordcase; # Perl 6 Programming

With a mather:

say"have fun working on perl".wordcase(:where({ .chars > 3 }));
# Have fun Working on Perl

With a customer filter too:

say"have fun working on perl".wordcase(:filter(&uc), :where({ .chars > 3 }));
# HAVE fun WORKING on PERL

Default method for constructing (create + initialize) new objects of a class. This method expects only named arguments which are then used to initialize attributes with accessors of the same name.

Classes may provide their own new method to override this default.

new triggers an object construction mechanism that calls submethods named BUILD in each class of an inheritance hierarchy, if they exist. See the documentation on object construction for more information.