#!/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 #### _ _ _ _ (_|| | |(_|>< _|