Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Use function as a regex

by Anonymous Monk
on Feb 15, 2018 at 16:50 UTC ( [id://1209238]=note: print w/replies, xml ) Need Help??


in reply to Re: Use function as a regex
in thread Use function as a regex

You can probably use straight-up $str =~ re() syntax with global searches as well, just make sure the re() returns a :lvalue. Either that or return a ref: $str =~ ${re()}.

Replies are listed 'Best First'.
Re^3: Use function as a regex
by Eily (Monsignor) on Feb 15, 2018 at 17:17 UTC

    I don't see any connexion between :lvalue and /g. $str =~ ${re()} isn't a global search but the output of qr is already a reference so /${re()}/g works, as pointed out by salva.

      Embarrasing. I read it exactly backwards. Something like while (str() =~ /(.)/g) can be made to work by using sub str :lvalue { state $x = "abcd" }.

      Sorry about the noise.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-24 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found