http://www.perlmonks.org?node_id=1019317


in reply to Unique key/value pair in Multiple key values pair in Hash

When you need something unique, think a hash:
#!/usr/bin/perl use warnings; use strict; use feature qw(say); my %hash; push(@{$hash{Lemon}}, 'Juice'); push(@{$hash{Lemon}}, 'Cake'); push(@{$hash{Lemon}}, 'Juice'); push(@{$hash{Lemon}}, 'Cake'); my %uniq; undef @uniq{@{$hash{Lemon}}}; say for keys %uniq;

Do you really need the array? If not, you can use HoH instead of HoA:

undef $hash{Orange}{Cake}; undef $hash{Orange}{Juice}; undef $hash{Orange}{Cake}; undef $hash{Orange}{Juice}; say for keys %{ $hash{Orange} };
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ