title: Declaring arrays globally in awk
body: <p>I wrote an awk script and now I am in the process of modularizing the same. I will just give a simple instance of what I have doe.</p>
  
  <pre><code>awk 
  BEGIN
  {
       declaring local variables 
  }
  
  {
        if(variable==A)
        {
              array[A]++;
              array1[A]++;
        }
  
  }
  END
  {
        print contents of array and array1
  }
  </code></pre>
  
  <p>I would like to do like the below using functions, I am just editing the action block, which is </p>
  
  <pre><code>{
        addArrays(A);
  }
  
  function addArrays(A)
  {
         array[A]++;
         array1[A]++;
  }
  </code></pre>
  
  <p>If I do like this I just want to know whether array and array1 contents can be accessed in the END statement. my doubt is whether array 1 and array 2 are locally declared inside the function. IF it is a local array . I just need to know how to make this as a global array so that I will be able to use this in the END function. Thank you.</p>