I have an array of arrays (3x6) and I pass it to a subroutine to loop thru and insert into a table. But when I pass the array to the sub the array seems to become a (1x6).
The end result of the above is that only the first array gets processed (i.e. ["ROLE", "ROLE TEST1", "HRSiteAdmin", "HR1", "Admin", 0 ]
I guess I do not understand the rules when it comes to passing arrays to subs. Any help is appreciated.
Code:
@rowarr = ( [ "ROLE", "ROLE TEST1", "HRSiteAdmin", "HR1", "Admin", 0 ],
[ "ROLE", "ROLE TEST2", "PayrollSup", "HR1", "Supervisor", 0 ],
[ "ROLE", "ROLE TEST3", "HRCorpExec", "HR1", "Executive", 0 ]
);
my $qry = qq{ INSERT INTO LAWIXREFNB VALUES ( ?, ?, ?, ?, ?, ? ) };
query_ora($qry, @rowarr);
sub query_ora
{
my $qry = shift;
my @records = shift;
$olen = @records;
print "length outer array : $olen\n";
foreach (@records)
{
....
...
}
The end result of the above is that only the first array gets processed (i.e. ["ROLE", "ROLE TEST1", "HRSiteAdmin", "HR1", "Admin", 0 ]
I guess I do not understand the rules when it comes to passing arrays to subs. Any help is appreciated.