for (1..10) { push @num, (int rand 3)+1 } for (@num) { print unless $seenit{$_}++; } for $x (1..3) { print $x if grep {/$x/} @num; }