title: How to declare an array in awk
body: <p>I have used awk to write a script. I am wondering how to <strong>declare an array</strong> in awk. </p>
  
  <p>I have read the <a href="http://www.math.utah.edu/docs/info/gawk_12.html#SEC113" rel="nofollow">gnu awk manual</a> and found nothing about <strong>declare</strong>.</p>
  
  <p>i want to test if index <code>ind</code> is in awk array <code>arr</code>.</p>
  
  <pre><code>echo 'awk' | awk 'BEGIN {arr} {if ('1' in arr) arr[ind] = 1}'
  </code></pre>
  
  <p>i do not declare <code>arr</code> as an array previously and run this in awk gives me such an error. </p>
  
  <pre><code>awk: cmd. line:1: (FILENAME=- FNR=1) fatal: attempt to use scalar `arr' as an array
  </code></pre>