Passing Array to awk

I'm trying to use the following command:

awk -v array1=${array1[@]} -f "filename.awk" input.txt

Then within filename.awk I want to access array1[n]. However, awk mistakes array1[2] (the third element of the array) for the input file. How I can pass awk this array?

It also appears that awk scripts can't understand ":-" or ${#var}. Is this correct?

awk -v array1="${array1
[*]}" -f "filename.awk" input.txt

Inside filename.awk

BEGIN{ split(array1,arr," "); print arr[1]}

--ahamed

awk is entirely its own programming language with its own variables that have nothing to do with the shell's. -v arguments are where shell variables and awk variables meet, to get them into awk you pass them in there as raw text.

Awesome, thanks!