Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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.

Comment on Re: searching an array?
Download Code
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?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-11-27 16:31 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls