in reply to References of Eternal Peril

You could probably, with a bit of work, use a hash and a list of values. Here's some relatively untested, unbeautiful stuff that makes me more likely to stick with declaring the variables in advance:
my %columns; # stuff here $sth->bind_columns( map { \${ $columns{$_} } @{ $sth->{NAME_lc} } ) || die("unable to bind columns: ", $sth->errstr); # dereference somehow, may not be correct while($sth->fetch) { print "<tr><td>$name</td><td>$columns{price}</td></tr>\n"; print "<tr><td colspan=\"2\">$columns{description}</td></tr>\n"; }
Update: Yeah, there's really no big benefit to doing it this way. :)

Replies are listed 'Best First'.
RE: Re: References of Eternal Peril
by mwp (Hermit) on Aug 11, 2000 at 05:07 UTC

    If I were going to use that approach, I would almost certainly drop the bind_columns altogether and do:

    while(my $columns = $sth->fetchrow_hashref) { print "<tr><td>$columns->{name}</td><td>$columns->{price}</td></tr +>\n"; print "<tr><td colspan=\"2\">$columns->{description}</td></tr>\n"; }

    But I'm trying to avoid that. Primarily, I asked this question in hopes of learning a bit more about hard references.

    Thanks for your help. :-)

    Alakaboo