Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: why is $1 cleared at end of an inline sub?

by choroba (Archbishop)
on Sep 17, 2021 at 20:52 UTC ( #11136850=note: print w/replies, xml ) Need Help??


in reply to Re^2: why is $1 cleared at end of an inline sub?
in thread why is $1 cleared at end of an inline sub?

The linked documentation explains it. Dynamic scope propagates inside blocks, but not outside.
my $s = 'abcdefg'; $s =~ m{abc(de)(fg)}; my $output = do { sprintf "1=%s, 2=%s", $1, $2 }; print $output; # 1=de, 2=fg

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11136850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2021-10-24 05:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?