while () { my $pw = @chars[map{rand @chars} (1..17)]; } unless ($_ ne $usedpw) { print "Your unique ID is: $pw\n"; }