in reply to Help Pass array as function params

#!/usr/bin/perl -w use strict; my @arrTest = (1,2,3); my @arrTest2 = (4,5,6); &GetData (\@arrTest , \@arrTest2 ); sub GetData { my ($messages, $count) = @_; # print the count; foreach (@ {$messages}) { print "$_! \n"; } # print the count; foreach (@ {$count}) { print "$_! \n"; } }

You had too many levels of references.

Update: OK, now I'm confused. When I answered this post the code looked like this:

my @arrTest = 1,2,3;
my @arrTest2 = 4,5,6;

Which, given the way that Perlmonks works, I interpreted as:

my @arrTest = [1,2,3]; my @arrTest2 = [4,5,6];

Hence, my remark about too many levels of references.

Now the code has been "fixed" and it looks identical to the fixes that I suggested. Which means it works and I look like I've wasted my time. Which is perhaps why someone has downvoted this node.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg