in reply to map {} list or do {} for list?

Or copying the hash onto itself, so to speak:
%hosts = map { $hosts{$_} == $table_count ? ($_, $hosts{$_}) : ()} key +s %hosts;