You can get all the records at once with $dbh->selectall_arrayref($query) and then rotate the resulting matrix.
Tested code ahead.
#!/usr/bin/perl -w use DBI; use strict; my $dbh = DBI->connect("DBI:mysql:test;host=localhost" . ";mysql_read_default_file=$ENV{HOME}/.my.cnf", undef, undef, {RaiseError => 1}) or die "can't connect\n"; my $query = qq{SELECT * from testgraph}; my $result = $dbh->selectall_arrayref($query); print "straight\n"; my @rotated =(); for my $row (@$result) { print "@$row\n"; for (0.. scalar @$row -1) { push @{$rotated[$_]}, $row->[$_]; } } print "rotated\n"; for my $row( @rotated) { print "@$row\n"; } $dbh->disconnect(); __END__ $ mysql -t -e "select * from test.testgraph" +------+------+------+ | c1 | c2 | c3 | +------+------+------+ | 1 | 10 | 100 | | 2 | 20 | 200 | | 3 | 30 | 300 | | 4 | 40 | 400 | +------+------+------+ $ perl testgraph.pl straight 1 10 100 2 20 200 3 30 300 4 40 400 rotated 1 2 3 4 10 20 30 40 100 200 300 400
_ _ _ _ (_|| | |(_|>< _|

In reply to Re: GD::GRAPH using DBI Data. by gmax
in thread GD::Graph using DBI Data. by jwherbold

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.