When you're passing arrays and hashes into and out of subs, it's (normally) necessary to pass a reference to the array, rather than the array itself.
If you don't pass a reference, the array is flattened, and passed out as a simple list - not something you want in this case.
You can correct this by having the GetLogFilesAndDatesIntoArray sub return a reference to the AoA, rather than trying to flatten the AoA and then return it. This is easy to do - just change the return to return \@filesanddates;.
Once you have the sub returning a reference, you should assign it to a scalar variable, rather than an array (a reference is always a scalar, regardless of what it refers to), and you can then use this variable to pass the array into the ExtractData sub - like this:
# note: $datalist now, it's a reference $datalist = GetLogFilesAndDatesIntoArray($logdirectory); ExtractData($datalist); # passes the reference into the sub
Finally, once you have the reference going into the ExtractData sub, you can deference it to retrieve the original array like this:
my $_filesanddates = shift; @filesanddates = @$_filesanddates; # dereferences the reference
There's a whole load of stuff on references and subroutines in perlsub and perlref.
Update: Thanks to broquaint for pointing out that I'm talking absolute rubbish .. oh well, eh. References are still a Good Thing in my book, but I guess that's a preference now, rather than a requirement...
Hope that helps a little ...
-- Foxcub
A friend is someone who can see straight through you, yet still enjoy the view. (Anon)
All code is untested unless explicitly stated otherwise.
In reply to Re: Passing Array of Arrays
by Tanalis
in thread Passing Array of Arrays
by marctwo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |