use strict; use DBI; # make the connection the way you have shown my @resultrow = (); my $resultref = $dbh->selectrow_arrayref("select ID from study where NAME='$unique_search_string_here'"); if (ref($resultref) eq 'ARRAY') { @resultrow = @{$resultref}; # do something with $resultrow[0] } else { # check for error in $DBI::errstr, etc. }