Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by haukex (Archbishop)
on Mar 02, 2021 at 05:24 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-28 18:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found