#!/usr/bin/perl
#
# eg3: unique elements example, third 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 y are the same as x (including x)?
	my $count = 0;
	foreach my $y (@array)
	{
		$count++ if $x == $y;
	}
	# unique if $count == 1 (x itself)
	push @uniq, $x if $count == 1;
}
my $str = join(',',@uniq); print qq($str\n);
