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

Re: Looking for alternative syntax for assigning variables based on regex matches

by haukex (Archbishop)
on Mar 02, 2021 at 05:24 UTC ( #11128988=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my ($x,$y) = $foo =~ /(hello)(world)/
        or die "failed to match";
    ...
    if ( $foo =~ /(?<x>hello)(?<y>world)/ ) {
        print $+{x}, $+{y};
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2022-11-27 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?