I'm not sure what you mean by "I ran this script", but your function is buggy. The error message tells you exactly what the problem is: you are trying to invoke a method named 'gsub' on an object of type Array (which has no such method).
The function seems to be getting its nesting levels wrong. The 'arguments' object passed into it is an array of the arguments to the function. You call it with one argument, itself an array. In your particular case, the value of 'arguments' seen by the function is [ [ 'dteam', '
vo.southgrid.ac.uk' ] ]. The function assumes that each element of 'arguments' supports a gsub() method, but that is not the case.
Among your alternatives are
- don't wrap the function arguments in an array
- make the function recognize array arguments and handle them appropriately
John