while( my( $comp, $bug_num ) = $sth->fetchrow_array() ) { if (($hash {$comp} eq '') ||($hash {$comp} == '' )) { $hash{ $comp }.=$bug_num; } else { $hash{ $comp}.=",$bug_num"; } }