Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: grep with multiple choice

by ferreira (Chaplain)
on Jun 11, 2007 at 11:55 UTC ( #620473=note: print w/replies, xml ) Need Help??

in reply to grep with multiple choice

grep { /^Julia_Roberts/ } @arr
should be enough. There's nothing particularly different with this "grep with multiple choice". The only thing it seems you are missing is that the grep block can match different values provided you code a suitable matching sub, like I did with a regex. If your problem is really to find out the array elements starting with $s, this will work:
grep { /^\Q$s\E/ } @arr; # regex with quoted interpolation # or grep { index $_, $s == 0 } @arr; # more efficient

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2023-02-05 23:01 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (33 votes). Check out past polls.