$data{RBS_query} = qq~select UserName from table where UserName <> '' and UserName not like 'deleted%' order by UserName~; #print "Query--> ".$data{RBS_query}."\n"; $data{cur} = $data{dbh}->prepare($data{RBS_query}); $data{cur}->execute or die($data{dbh}->errstr); $data{num} = $data{cur}->rows; print "RBS Rows--> ".$data{num}."\n"; while(my @rows = $data{cur}->fetchrow_array()){ #print "Username --> ".$rows[0]."\n"; if(grep {$_ eq $rows[0]} @RBS_User_Names){ # print "Value exist in array\n"; }else{ push(@RBS_User_Names,$rows[0]); #print "value doesnot exist in array\n"; } }