http://www.perlmonks.org?node_id=542573

I'm finding myself using this idiom a lot for a current project. Adjust to taste for your own applications.
# given a DBI handle $dbh, a database table "foo" with a column "bar" print join "\n", map join("\t", @$_), @{$dbh->selectall_arrayref( q{ select bar from foo } )};

Replies are listed 'Best First'.
Re: Output results from a DBI select query in one line
by merlyn (Sage) on Apr 11, 2006 at 16:12 UTC
      Or, a couple of characters shorter than that (if we don't count loading Dumper):
      print Dumper $dbh->selectall_arrayref("SELECT one, two FROM three WHER +E four=? AND five=?",{},4,5);
        Either merlyn's or jZed's examples are fine for diagnostics. The original, however:
        • won't truncate values as dump_results does
        • provides more human-readable output than Data::Dumper's structures
        But feel free to use whatever works for you. Mine was just more appropriate for my project.