Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: matching an array of alternates

by perlmonkey (Hermit)
on Jun 24, 2000 at 02:27 UTC ( [id://19679]=note: print w/replies, xml ) Need Help??


in reply to matching an array of alternates

This should do the trick:
@latin_am=("Ecuador","Mexico"); $regex = join ("|", @latin_am); open( FILE, 'input.txt' ) or die "input.txt: $!"; @lines = grep { /$regex/o } <FILE>;
@lines will hold all the lines of the file 'input.txt' that match any of the phrases in @latin_am

Log In?
Username:
Password:

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

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

    No recent polls found