Match is a class defining the type of the objects that you get (for example in variable $/) when a regex match is successful or through regex captures into $0, $1, etc. or into named captures.
JJ Merelo accurately responded that such objects can be coerced into strings with the tilde ~ prefix operator. For example, in the code of your original post: $D0 = ~$0; $D1 = ~$1; # ... You may also used double quotes around the match object to the same effect. Le jeu. 20 déc. 2018 à 23:17, ToddAndMargo via perl6-users < perl6-us...@perl.org> a écrit : > >> El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users > >> <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> escribió: > >> > >> Hi All, > >> > >> Exactly what is type "Match"? > >> > >> Here I want $D0..$D3 to only be strings. And it throws a match > error. > >> > >> $ p6 'my $x="11.2.3.4"; my Str $D0; my Str $D1; my Str $D2; my Str > $D3; > >> $x~~m{ (<:N>) [.] (\d+) [.] (\d+) [.] (\d+) }; $D0 = $0; $D1 = $1; > >> $D2 = > >> $2; $D3 = $3; print "$D0 $D1 $D2 $D3\n";' > >> > >> Type check failed in assignment to $D0; expected Str but got Match > >> (Match.new(from => 1, made ...) > >> in block <unit> at -e line 1 > >> > >> Here is my work around: > >> > >> $ p6 'my $x="11.2.3.4"; my Str $D0; my Str $D1; my Str $D2; my Str > $D3; > >> $x~~m{ (<:N>+) [.] (\d+) [.] (\d+) [.] (\d+) }; $D0 = $0.Str; $D1 = > >> $1.Str; $D2 = $2.Str; $D3 = $3.Str; print "$D0 $D1 $D2 $D3\n";' > >> 11 2 3 4 > >> > >> > >> Many thanks, > >> -T > > On 12/20/18 2:08 PM, JJ Merelo wrote: > > Put a wriggly ~ in front of $0 to turn it into a Str; it's the Str > > contextualizer > > > > Hi JJ, > > You did not actually answer the question I asked. What is type "Match"? > > And I am missing something in your answer > > This works: > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] (\d+) }; > $D0 = $0.Str; $D1 = $1.Str; print "$D0 $D1\n";' > 11 2 > > > This does not. One with a space after the ~, one without it. > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] (\d+) }; > $D0 ~$0; $D1 ~ $1; print "$D0 $D1\n";' > WARNINGS for -e: > Useless use of "~" in expression "$D1 ~ $1" in sink context (line 1) > Useless use of "~" in expression "$D0 ~$0" in sink context (line 1) > Use of uninitialized value of type Str in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it to > something meaningful. > in block <unit> at -e line 1 > Use of uninitialized value of type Str in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it to > something meaningful. > in block <unit> at -e line 1 > Use of uninitialized value of type Str in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it to > something meaningful. > in block <unit> at -e line 1 > Use of uninitialized value of type Str in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it to > something meaningful. > in block <unit> at -e line 1 > > I am confused, > -T >