$pw = join(@chars[map{rand @chars} (1..17)]; while ( grep { $pw eq $_ } @stored ) { $pw = join(@chars[map{rand @chars} (1..17)]; }