in reply to creating an array from MySQL results

The code itself does not appear to have any error. I modified your code a little bit to work with real table/column I have, and it worked for me:

use DBI; use Data::Dumper; use strict; use warnings; my $dsn = "DBI:mysql:database=test;host=foo"; my $dbh = DBI->connect($dsn, 'root', 'bar', {RaiseError => 1}); my $data = qq(SELECT person FROM or_mod); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my @a; while(my $ref = $sth->fetchrow_arrayref) { push @a, $ref->[0]; } print Dumper(\@a);

The loop part actually can be changed to a map:

my @a = map {$_->[0]} @{$sth->fetchall_arrayref};