if( $a ne " " ) { if( !exists $Hash{$a} ) { $Hash{$a} = $b; } else { $is_there = 0; $tmp_is_there = 0; $temp = $Hash{$a}; foreach my $elt ( @{$Hash{$a}} ) { if ($elt eq $b) { $is_there = 1; } if ($elt eq $temp) { $tmp_is_there = 1; } } if ( !$is_there ) { push @{$Hash{$a}}, $b; } if ( !$tmp_is_there ) { push @{$Hash{$a}}, $temp; } } }