I though the code below would work but I think it is not dereferencing the array:
#!/usr/bin/perl
# ARRAY OF HASHES
$val[0]{‘CELL1′} = "0cell1";
$val[0]{‘CELL2′} = "0cell2";
$val[1]{‘CELL1′} = "1cell1";
$val[1]{‘CELL2′} = "1cell2";
for my $i (0..$#val) {
print "$val[$i]{‘CELL1′} $val[$i]{‘CELL2′}\n";
}
$res = &mysub(\@val);
print "RESULT: $res\n";
sub mysub {
my $ref = shift ; # $ref is a reference to an array of HASHES
my @valIN=@{$ref}; # try to dereference it
for my $i (0..$#valIN) {
print "$valIN[$i]{‘CELL1′} $valIN[$i]{‘CELL2′}\n";
}
return "DONE";
}
I looked and looked and found nothing wrong with you code, so I tried it out. And guess what? It works:
Output:
0cell1 0cell2
1cell1 1cell2
0cell1 0cell2
1cell1 1cell2
RESULT: DONE