Array arguments are passed by reference
 
 
 

Arrays are passed by reference. If you pass an array as an argument to a procedure and modify that argument within the procedure, the array will have the modified values upon return from the procedure call. For example:

proc fred( string $myArray[] ) {
 for ( $i=0; $i<size($myArray); ++$i ) {
 $myArray[$i] = "fred";
 }
 $myArray[$i] = "flintstone"; // add to the end of the array.
 }
 string $a[] =`ls -geometry`;
 print("Before call to fred\n");
 print $a;
 fred($a);
 print("After call to fred\n");
 print $a;
produces this output: 
Before call to fred
nurbConeShape1
nurbConeShape2
nurbSphereShape1
nurbSphereShape2
After call to fred
fred
fred
fred
fred
flintstone