Will do, thanks

----- Original Message ----- 
From: "Micah Cowan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 4:11 PM
Subject: Re: [vox-tech] Perl question, DBI - Why no selectcol_array method?


> On Fri, Apr 27, 2001 at 03:28:58PM -0500, Jay Strauss wrote:
> > In DBI there is:
> > 
> >       $ary_ref = $dbh->selectrow_arrayref($statement);
> >       @row_ary = $dbh->selectrow_array($statement);
> > 
> > but only
> > 
> >       $ary_ref = $dbh->selectcol_arrayref($statement);
> > 
> > Why??? (i.e why no @col_ary = $dbh->selectcol_array($statement))
> 
> Dunno.  You'll have to ask the author  :)
> 
> > 
> > I know how to access the individual elements (i.e. $ary_ref->[0])
> > 
> > But how do I put it an $ary_ref in a foreach?
> > 
> > foreach my $name ($ary_ref = $dbh->selectcol_arrayref($statement))
> > {
> > ...stuff;
> > }
> 
> Well,
> 
> foreach my $name (@{ $ary_ref = $dbh->selectcol_arrayref($statement)})
> {
>   ...stuff;
> }
> 
> would, since variable type-prefixes can be followed by a "block" whose
> value is a reference to the type indicated by the prefix.
> 
> But, I'd prefer:
> 
> $ary_ref = $dbh->selectcol_arrayref($statement)
> foreach my $name (@$ary_ref)
> {
> ...stuff;
> }
> 
> -Micah


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to