On Fri, Dec 6, 2019 at 10:54 PM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>
> On 2019-12-06 22:38, ToddAndMargo via perl6-users wrote:
> >>> On Fri, Dec 6, 2019 at 9:28 PM ToddAndMargo via perl6-users
> >>> <perl6-us...@perl.org> wrote:
> >>>>
> >>>> On 2019-12-06 20:33, William Michels via perl6-users wrote:
> >>>>> say $/;
> >>>>
> >>>> First I have seen of `$/`.  Is it any relation to `$_`?
> >
> > On 2019-12-06 22:11, William Michels via perl6-users wrote:
> >> Hi Todd, yes in a sense "$/" is related to "$_" in that they're both
> >> variables that get filled with values behind the scenes by Raku/Perl6.
> >> You already know that "$_" is the general default 'topic' variable
> >> (same as in Perl 5, see Ref#1 below).
> >>
> >>  From Ref#2 below: " $/ is the match variable. It stores the result of
> >> the last Regex match and so usually contains objects of type Match."
> >> Apparently "$/" in Raku/Perl6 has replaced a series of variables that
> >> were used in Perl5, including  "$`", "$&", and "$'" which "are gone
> >> from Raku" (Ref#3 below):
> >>
> >> 1. https://docs.raku.org/language/5to6-perlvar#$ARG,_$_
> >> 2. https://docs.raku.org/syntax/$$SOLIDUS
> >> 3.
> >> https://docs.raku.org/language/5to6-perlvar#Variables_related_to_regular_expressions
> >>
> >>
> >> HTH, Bill.
> >
> > Awesome!  I am going to have fun with this!  I do
> > A LOT of regex's.
> >
> > Thank you!
>
>
>
> Tells me what was matched!  Oh I am going to have a
> lot of fun with this!
>
> my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '\\\\' /x/; say $/
> 「\\」
>
> my $x = Q[abcdef]; ( my $y = $x ) ~~ s/ .*? (cd) (e) .* /x/; say $/
> 「abcdef」
>   0 => 「cd」
>   1 => 「e」
>
> my $x = Q[abcdef]; ( my $y = $x ) ~~ m/ .*? (cd) (e).* /; say $/
> 「abcdef」
>   0 => 「cd」
>   1 => 「e」
>
> my $x = Q[abcdef]; ( my $y = $x ) ~~ m/ .*? (cd) (e).* /; for $/ {say $_};
> 「abcdef」
>   0 => 「cd」
>   1 => 「e」
>
> my $x = Q[abcdef]; ( my $y = $x ) ~~ m/ .*? (cd) (e).* /; say $/[0]; say
> $/[1]
> 「cd」
> 「e」

Adding some:

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> my $x = Q[\:\\::];
\:\\::
> say $/ if $x ~~ m/ '\\\\' /;
「\\」
> say $/ if $x ~~ rx/ '\\\\' /;
「\\」
> say $x
\:\\::
> $*VM
moar (2019.07.1)
>

HTH, Bill

Reply via email to