in reply to Re: Is there an InString-like function?
in thread Is there an InString-like function?

You've heard of grep, right?
print grep { $_ eq $var } qw( 1 2 3 4 5 ) ? "Found.\n" : "Not found.\n +";
Note though that grep loops over the entire array everytime, so for large arrays, simon.proctor's function would be better.

ar0n ]

Replies are listed 'Best First'.
Re: (ar0n) Re (2): Is there an InString-like function?
by tigervamp (Friar) on Jul 24, 2001 at 02:23 UTC
    Thanks, this is perfect. I was looking for something better than index and you example works great, especially since I am running the test against many multi-lenth strings, not single characters. Unfortunately, the documentation on the "grep BLOCK LIST" is severly lacking so I appreciate your insight. If I ever need to work with long lists, I will use a pattern matching solution like the one given by wiz which also works well.

    Thanks again,
    tigervamp