my %hash_docs; while(my ($doc) = $sth_docnames->fetchrow_array()){ $hash_docs{$doc}++; } if(scalar(keys(%hash_docs)) > 1){ doc_vorhanden(%hash_docs); }