Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 meditating upon the Monastery: (3)
As of 2023-02-02 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (15 votes). Check out past polls.

    Notices?