my @column_names = @{$_read_sth->{NAME_lc}); local $\ = "\n"; # v---- not a @ while (my $row = $_read_sth->fetchall_arrayref) { print join ",", @$row; # Extremely oversimplified }