awk - array elements as condition

Hi,

can I use array elements ( all ) in conditional statements?
the problem is ,the total number of elements is not known.

e.g

A is an array with elements - 1,2,3

now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this

if ( $1 ~ /^A[1]$|^A[2]$|^A[3]$/) { print  YES }

but i want something like..

if ( $1 ~ /^A[1]$|^A[2]$|^A[3]$/| logical OR till array's last element) { print  YES }

Is that possibe?

When you say:

$1 ~ /^A[1]$/

That would be equivalent (if it worked) to:

$1 == A[1]

You can't use / ... / to do what you are trying to do.

Have a look at:
The GNU Awk User's Guide
(7.5 Scanning All Elements of an Array)