Help for this page

Select Code to Download


  1. or download this
    Getopt::Long::Configure ("bundling");
    
  2. or download this
    *   No space between function name and its opening parenthesis.
    
  3. or download this
    ## PARSE AND SET COMMAND-LINE OPTIONS
    ## -----------------------------------------------------
    
  4. or download this
    my %flags=('symbols', 0, 'numbers', 0, 'uppercase', 0, 'lowercase', 0,
    + 'confusable', 0, 'help', 0, 'qty', 1);
    
  5. or download this
    my %flags=map {$_ => 0 }
      qw/symbols numbers uppercase lowercase confusable help);
    $flags{qty}=1;
    
  6. or download this
    my $pwdchars = join( '', map {chr} ( 0x21 .. 0x7e ));
        $pwdchars =~ s/\d+//    if ( $flags{numbers} );
    ...
        $pwdchars =~ s/[a-z]+// if ( $flags{lowercase} );
        $pwdchars =~ s/[_\W]+//g if ( $flags{symbols} );
        $pwdchars =~ tr/1Il0O//d  if ( $flags{confusable} );
    
  7. or download this
    my $pwdchars = join '', map chr, 0x21 .. 0x7e;
    for ($pwdchars) {
    ...
        s/[_\W]+//g if $flags{symbols};
        tr/1Il0O//d if $flags{confusable};
    }
    
  8. or download this
    # If user triggered the --help option flag, display and exit
    if ($flags{help}) {            
        &DisplayUsage();    
        exit();
    }
    
  9. or download this
    print(USAGE), exit if $flags{help};
    
  10. or download this
    my $kill=0;        # flag to stop the script if input is invalid (or -
    +-help is used)
    my @errmsg;        # error message descriptions
    
  11. or download this
    if ($flags{qty} == 0 || $flags{qty} < 0) {
        $flags{qty}=1;
    }
    
  12. or download this
    $flags{qty}=1 if $flags{qty} <= 0;
    
  13. or download this
    $flags{qty}=1 unless $flags{qty} > 0;
    
  14. or download this
    $flags{qty}=1 unless $flags{qty} >= 1;
    
  15. or download this
    if ( length($pwdchars) == 0) {
    
  16. or download this
    if ($pwdchars) {
    
  17. or download this
    # Check that user has passed only 1 argument (LENGTH) other than optio
    +ns flags, warn user, kill script
    if ($#ARGV > 0 || $#ARGV < 0) {
    
  18. or download this
    unless (@ARGV==1) {
    
  19. or download this
    # Check for only numeric input in LENGTH argument, warn user, kill scr
    +ipt
    if ($ARGV[0] !~ /^[0-9]+$/) {
    
  20. or download this
    # If any of the above validation tests triggered the $kill flag...
    if ($kill == 1) {                     
    ...
        print "** --------------------------------------------------------
    +---------------\n\n";
        exit();                         # exit script
    }
    
  21. or download this
        for ( 0..$pwdlen-1 ) {
                $pwd .= substr( $pwdchars, rand( $limit ), 1 );
        }
    
  22. or download this
    #!/usr/bin/perl
    
    ...
    }
    
    __END__
    
  23. or download this
    genpass -snul 10
    genpass
    ...
    genpass abc def
    genpass -snul abc
    genpass -snul abc def
    
  24. or download this
    C:\temp>genpass -scq10 10
    v36Bhe2mE4
    ...
    2ZqYMq6NS4
    jRUhKdfs46
    mV2qZJVnWb