Printing passwords successively

D

Diego Alvarez

I've got this code snippet:

@char=("A".."Z","a".."z",0..9);
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
 
A

A. Sinan Unur

I've got this code snippet:

@char=("A".."Z","a".."z",0..9);
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?

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

#!/usr/bin/perl

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";
}

__END__


--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top