Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: perl6 match variable

by grondilu (Friar)
on Sep 10, 2014 at 09:56 UTC ( #1100109=note: print w/replies, xml ) Need Help??


in reply to Re: perl6 match variable
in thread perl6 match variable

The match object $/ in not visible on its own because subst evaluates the regex in a different scope.

Does it? Because when I write, e.g:

say "foo".subst: /(fo)o/, {$/[0].flip}

I get, as I expected, "of"

Replies are listed 'Best First'.
Re^3: perl6 match variable
by jeckyhl (Novice) on Sep 10, 2014 at 21:32 UTC

    And now let's try

    for dir(".") -> $file { say "foo".subst: /(fo)o/, {$/[0].flip}; last; }

    guess what happens ?...

    we get an empty string!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1100109]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2018-02-25 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (312 votes). Check out past polls.

    Notices?