in reply to Finding duplicate keys

Fixed a bug - replaced the hash value undef() with the key name.

Given @list_a and @list_b I construct an anonymous hash of @list_a and then immediately extract a slice from that hash using @list_b as the keys to fetch. @dups now contains the intersection of both lists.

@dups = @{ { map { $_, $_ } @list_a } }{ @list_b } # Broken out. # Duplicate each key - the key must also be the value since it will be + retrieved later. This creates a list useable as a hash. map { $_, $_ } @list_a # Create an anonymous hash from that list { ... } # Fetch a slice from a hash ref using @list_b @{ ... }{ @list_b } # Into dups @dups = ...