[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] What's that structure name?



On Sep 1, 2008, at 8:33 PM, Dave Thacker wrote:
while (my ($name, $age, $st, $tk, $ps, $sh ) = $sth->fetchrow_array () ) {
        print "$name, $age, $st, $tk, $ps, $sh \n";
    }

How do I refer to that array if I want to send it into a sub? Or do I need to
assign it to an array of my own.....

You don't have an array there, you just have a list. You can create an array called @row if you want, and pass that to your sub:

while (my @row = $sth->fetchrow_array()) {
   my_sub(@row);
}

sub my_sub {
   my (@row) = @_;
   print join ", ", @row;
   print "\n";
}

HTH,

j