Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Golfing password creation

by moritz (Cardinal)
on Jul 29, 2009 at 06:36 UTC ( [id://784139] : note . print w/replies, xml ) Need Help??


in reply to Golfing password creation

Without changing your algorithm in any way, you can gain a few characters by removing unnecessary quotes, and substituting $o with $_. Since say and length both default to $_ the change of the variable removes four extra characters.
perl -E '@a=(0..9,A..Z,a..z);$_.=$a[rand@a]while 8>length;say'

And here's a completely non-golfed Perl 6 version that's even shorter:

perl6 -e 'say (0..9, "A".."Z", "a".."z").pick(8, :repl)' JIEFoUyiq

On my Linux box this is even shorter:

$ pwgen -s 8 1 mUM6fAiz

But I guess not using Perl in a golfing challenge is cheating ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://784139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-02-06 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found