Hi Guys
I was wondering if you could help me.
I have a multi-dimensional array and I would like to pass it to a subroutine
as follows :
my @multi_array = ([1,2,3,4], [5,6,7,8]);
my @result = process_array(@multi_array);
print "The result is : @result\n";
sub process_array {
my @array_processed;
my @array_given = $_[0];
$select_data = "select A, B, C, D
from Table X
where A = ? and B = ? and C = ? and D = ?";
$sth = $dbh->prepare($select_data)
or die "Can't prepare SQL statement: ", $dbh->errstr(), "\n";
for (@array_given) {
$sth->bind_param(1, @$_->[0]);
$sth->bind_param(2, @$_->[1]);
$sth->bind_param(3, @$_->[2]);
$sth->bind_param(4, @$_->[3]);
$sth->execute();
$sth->bind_columns(undef, \$A, \$B, \$C, \$D);
while ($sth->fetch()) {
$new_array = join("|", $A, $B, $C, $D);
unshift(@array_processed, $new_array);
}
}
$sth->finish();
return @array_processed;
}
I am expecting as output the following :
The result is 1,2,3,4
The result is 5,6,7,8
The actual output I am getting is :
The result is 1,2,3,4
What happened to 5,6,7,8 ?
I would be most grateful for any advice.
Thanks in advance
Tony