in reply to searching an array?
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.if ( grep(/^$path$/, @directories) ) { #exact input to array element s +earch print "$path exists in the array of directories"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: searching an array?
by Whitchman (Novice) on Mar 15, 2002 at 22:27 UTC |