my $names = $dbh->selectcol_arrayref( "select name from addressbook where name like ?", undef, $name ) or die "select failed. " . $dbh->errstr; my @case = @$names; # If you'd rather deal with an array print "@case\n"; # prints out ALL of the names selected.