Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: regex with arrays and variables

by Rahul6990 (Beadle)
on Apr 26, 2013 at 06:29 UTC ( #1030777=note: print w/ replies, xml ) Need Help??


in reply to regex with arrays and variables

Hi

Shorter and working the same.
You do not require to add "(" and ")" to your regex.

my @array = ("foo {abc123}\n", "bar {def456}\n", "baz {ghi789}\n"); my @array2 = ("foo", "bar", "quux"); foreach my $i (@array) { chomp $i; $regex .= join "|", @array2; if ($i =~ m/$regex/) { print "$i is in array2\n"; next; } # Do something with $i now. }

Happy Programming...


Comment on Re: regex with arrays and variables
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-07-29 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls