PassingAnArray

  awk -v list='foo,bar,baz' '
    BEGIN {
      n=split(list, array, /,/)
      # now: array[1] == "foo", array[2] == "bar", ...
      for (idx in array) 
        map[array[idx]] = k
    } 
    $0 in map { ... }'
   awk '
       # cmp as awk program
       NR == FNR { array[NR] = $0; next } 
       !(FNR in array && $0 == array[FNR]) { result = 1; exit } 
       END { exit (NR != 2 * FNR || result + 0) }
  ' file1 file2

With gawk one could use ARGIND == 1 instead of NR == FNR, which is working also for an empty file file1.

For an explanation of this technique see: ComparingTwoFiles