To split e.g. mins-2 into component parts of units name and order, this does what I want
sub split-order ( $string ) {
my Str $i-s = '1';
$string ~~ / ( <-[\-\d]>+ ) ( \-?\d? ) /;
$i-s = "$1" if $1 ne '';
return( "$0", +"$i-s".Int );
}
It seems that perl6 should be able to pack this into a much more concise phrasing. I need default order of 1 where there is no trailing number.
I am probably being a bit lazy not matching the line end with $. Trying to avoid returning Nil as that is not useful to caller.
Anyone with a better turn of phrase?