for my $key ( keys %hosts ) { if ( $hosts{$key} != $table_count ) { delete $hosts{$key}; } }