Re: Compare all array values without a loopby radiantmatrix (Parson)
|on Oct 19, 2004 at 14:35 UTC||Need Help??|
You could join the array into a scalar with an unusual character as a separator, then use a match.
The $sep on either side of the join() ensures that any potential match will begin and end with chr(1). You can pick other separator characters, as long as you can be sure they will not exist in your array (chr(1) is a pretty unlikely thing to find).
Of course, it would be better to use hash-keys if you can...
If you're avoiding multiple loop passes for performance, then you could use a one-time loop to convert the array to a hash:
"Users are evil. All users are evil. Do not trust them. Perl specifically offers the -T switch because it knows users are evil." - japhy