my $data = qq(SELECT catname, path, root FROM categories WHERE root = "1" ORDER BY catname ASC); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($catname, $path, $root); $sth->bind_columns(\$catname, \$path, \$root); while($sth->fetch) { print qq~ $catname
~; }