my @things = qw(foo bar foo baz baz); my %hash; $hash{$_}++ for @things; print scalar keys %hash; # 3