in reply to Re: Variable still not holding contents
in thread Variable still not holding contents

Good catch!
Actually, the only problem with his code as given was the missing join character as the first argument to join. Inserting a null string:   $pw = join('',@chars[map{rand @chars} (1..17)]; This works, because map{rand @chars} (1..17) does indeed generate a list of 17 indices, each in the proper range for the @chars array. (They're floating point, but they get intified when used as indices.)
That said, it's not how I would have done it. I would have written   $pw = join '', map { $chars[ rand @chars ] } 1..17;

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.

Replies are listed 'Best First'.
Re: Re: Re: Variable still not holding contents
by graff (Chancellor) on Jan 08, 2003 at 05:54 UTC
    ...the only problem with his code as given was the missing join character...

    And then there's the missing close paren that needs to be added after the close square bracket. Anyway, I agree that you're latter approach is clean and easy enough -- still, I think that having a subroutine with a name that indicates what the **** is going on is a really nice feature.