Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by rsFalse (Chaplain)
on Mar 02, 2021 at 10:28 UTC ( #11129009=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -wle '$foo = "a hello w"; $foo = $foo =~ s/(?=.*(hello)).*/$1/sr;
    + print $foo'
    
  2. or download this
    hello
    
  3. or download this
    ...; print $foo =~ s/(?=.*(hello)).*/$1/sr;
    
  4. or download this
    ...; $foo =~ /hello(?{ $foo = $& })/; print $foo
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2022-10-02 09:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (8 votes). Check out past polls.

    Notices?