Printing passwords successively

Discussion in 'Perl Misc' started by Diego Alvarez, Sep 16, 2008.

  1. 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
    Diego Alvarez, Sep 16, 2008
    #1
    1. Advertising

  2. Diego Alvarez <> wrote in news:48d005d2$0$13388
    $:

    > 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 <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://www.rehabitation.com/clpmisc/
    A. Sinan Unur, Sep 16, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon B
    Replies:
    7
    Views:
    7,475
    =?Utf-8?B?SmFzb25DaG9p?=
    Jan 30, 2006
  2. JustSomeGuy
    Replies:
    13
    Views:
    494
    msalters
    Dec 9, 2004
  3. iffy agbim
    Replies:
    1
    Views:
    90
    Mark Andrews
    May 24, 2004
  4. iffy agbim
    Replies:
    0
    Views:
    91
    iffy agbim
    May 21, 2004
Loading...

Share This Page