I am mulling over a best practice for passing hash references for return data to/from functions.
On the one hand it seems intuitive to pass only input values to a function and have only return output variables. However in Perl, passing hashes can only be done by reference so it is a bit messy and would seem more of an opportunity to make a mistake.
The other way is to pass a reference in the input variables, but then it has to be dealt with in the function and it may not be clear what is an input and what is a return variable.
Anyone have a best practices regarding this?
return references to an array and a hash, then dereference it.
($ref_array,$ref_hash) = $this->getData('input');
@array = @{$ref_array};
%hash = %{$ref_hash};
pass in references (@array,%hash) to the function that will hold the output data.
$this->getData('input',\@array,\%hash);