Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: searching an array?

by Parham (Friar)
on Mar 15, 2002 at 16:22 UTC ( #152016=note: print w/ replies, xml ) Need Help??


in reply to searching an array?

if ( grep(/^$path$/, @directories) ) { #exact input to array element s +earch print "$path exists in the array of directories"; }
that's how i'd do it. If grep() gets anything (in the conditional if statement), the program will tell you that your input exists in the array. If you want partial searches in the array, remove the ^ or $ or both depending on whether you want your input to exist in the beginning or the ending or anywhere of each array element.

Replies are listed 'Best First'.
Re: Re: searching an array?
by Whitchman (Novice) on Mar 15, 2002 at 22:27 UTC
    Thanks everyone! That did the trick. You guys are fast!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2016-06-26 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (328 votes). Check out past polls.