Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Password (pseudo)casual

by karlgoethebier (Curate)
on Jan 24, 2013 at 19:29 UTC ( #1015214=note: print w/ replies, xml ) Need Help??


in reply to Password (pseudo)casual

Just a variation on this theme using the buildin features:

#!/usr/bin/perl + use strict; use warnings; my ( @l, @u, @n, @s, @p, $i, $j ); open( URANDOM, "</dev/urandom" ) || die $!; read( URANDOM, $_, 4 ); close URANDOM; srand( unpack( "L", $_ ) ); @l = ( "a" .. "z" ); @u = ( "A" .. "Z" ); # @n = ( 0 .. 9 ); + # @s = ( + # '#', ',', ' ', + # qw( ! " $ % & ' ( ) * + - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ + ) # ); + push( @p, splice( @l, int( rand(@l) ), 1 ) ) for ( 1 .. 10 ); push( @p, splice( @u, int( rand(@u) ), 1 ) ) for ( 1 .. 10 ); # push( @p, splice( @l, int( rand(@l) ), 1 ) ) for ( 1 .. 3 ); + # push( @p, splice( @u, int( rand(@u) ), 1 ) ) for ( 1 .. 3 ); + # push( @p, splice( @n, int( rand(@n) ), 1 ) ) for ( 1 .. 2 ); + # push( @p, splice( @s, int( rand(@s) ), 1 ) ) for ( 1 .. 2 ); + for ( $i = @p ; --$i ; ) { $j = int( rand( $i + 1 ) ); next if $i == $j; @p[ $i, $j ] = @p[ $j, $i ]; } print join( "", @p ) . qq(\n); __END__

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»


Comment on Re: Password (pseudo)casual
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-08-28 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (264 votes), past polls