my $parent = 'xxx xxx xxx'; my $count = my @items = split(/ /, $parent); print "$count\n"; # 3 [download] Since you have a count, all you need to check if there are duplicates is check the count. if ($count < 1) { print "None\n"; } elsif ($count < 2) { print "Unique\n"; } else { print "$count\n"; }