Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Creating regex from arrays

by Kageneko (Scribe)
on Jul 29, 2003 at 15:40 UTC ( [id://278868]=note: print w/replies, xml ) Need Help??


in reply to Creating regex from arrays

Hmm, you could do something like this:
my $results = join "|", @results; my $results_re = qr/$results/; ... if ( $name =~ /$results_re/ ) { ... }
Undoubtedly, there is an easier way to do it, but that's what springs to mind. Using qr// allows you to compile the regex only once if you re-use the same results (and regex) over and over.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2024-04-25 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found