use DBI; my $dbh = DBI->connect(...); my $stmt = 'select id from items where foo > 42'; my @ids = @{ $dbh->selectcol_arrayref($stmt) };