Trimming whitespace from both ends of a string

Author: stmuk

You have a string with leading and/or trailing whitespace you wish to remove

Source code: 01-19trim-whitespace.p6

#!/usr/bin/env perl6

use v6;

my $string = "\t the cat sat on the mat  ";

$string.=trim;

say :$string.perl;