Printing passwords successively

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've got this code snippet:

  do{print join("",@char[map{rand @char}(1..8)])}while(<>);

In order to get the next password, I'll have to hit ENTER. How would I
have to modify the code to print e.g. 1000 pws successively without
having to do this?

TIA, Diego

Re: Printing passwords successively


Quoted text here. Click to load it

Replace the while loop reading from STDIN with the appropriate for loop:


use strict;
use warnings;

my @char = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9);

for ( 1 .. 1_000 ) {
    print join(q{}, @char[ map{rand @char}(1..8) ] ), "\n";


(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW: /

Site Timeline