I am using awk. I would like to modularize my code and I would like to know whether variables declared inside a function is a local or global.. For instance
  main script
  update()
  function update()
  {
      array[1]="hi"
  }
I would like to know whether the array which is declared inside the function is a local or a global .. If it is not local then.. what is the concept of local variable in awk.
They are global:
awk 'function update() { array[1]="hi" } BEGIN { update(); print array[1];}'
hi
To make it local, you need a little trick, pass it as an argument:
awk 'function update(array) { array[1]="hi" } BEGIN { update(); print array[1];}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With