in reply to Please Review First Program: Random Password Generator
This is not critism. Style is a very subjective thing, and more people are likely to adhere more closely to yours than mine.
But ... what advantages do you see for your program over this which I believe to be roughly functionally equivalent? :
#! perl -slw use strict; use List::Util qw[ shuffle ]; our( $L, $N, $S, $h, $p ); our $l //= 14; if( $h ) { print "$0 [-L -N -S -p -l=nn -h]\n", <DATA>; exit; } $l = $l <= 0 ? 14 : $l > 100 ? 100 : $l; my @chars; push @chars, 'a'..'z', 'A'..'Z' unless $L; push @chars, 0 .. 9 unless $N; push @chars, split'', q[`~!@#$%^&*()_+-=\,./<>?;':"[]{}] #' unless $S; printf "%s%s\n", $p ? '' : 'Password: ', join'', (shuffle @chars)[ 0 .. $l-1 ]; __DATA__ -h this help -p supress "Password:" -l=nn length to generate: 1 .. 100; default:14 -L supress letters (upper and lower) -N supress digits -S supress symbols `~!@#$%^&*()_+-=\,./<>?;':"[]{}
And which do you find easier to follow?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please Review First Program: Random Password Generator
by hakkum (Acolyte) on Feb 04, 2011 at 06:09 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2011 at 07:06 UTC | |
by ikegami (Patriarch) on Feb 05, 2011 at 05:31 UTC |