foreach my $key ( keys %hash ) { push @draw, ($key) x $hash{$key}; push @mega, ($key) x $hash{$key} if exists $bonus{$key}; }