my $column = "rent"; my $rows= dbh->selectall_arrayref(qq{SELECT DISTINCT $column FROM owner}); for (@$rows) { print "@$_\n" };