#!/usr/bin/perl
#
# eg4: unique elements example, fourth version..
#

use strict;
use warnings;

my @array = ( 17, 5, 3, 17, 2, 5, 7, 6, 6, 10, 3 );

# build @uniq, an array of all unique elements of @array
my @uniq;
foreach my $x (@array)
{
	# how many elements are the same as x (including x)?
	my $count = grep { $_ == $x } @array;

	# unique if $count == 1 (x itself)
	push @uniq, $x if $count == 1;
}
my $str = join(',',@uniq); print qq($str\n);
