use v6; my $x = "this is a test".subst(/\s/, '-', :g); # or my $x = "this is a test"; $x.=subst(/\s/, '-', :g);