1: #! /usr/bin/perl -w
   2: use strict;
   3: 
   4: # Creates passwords from a customizable list of characters
   5: #   (To make it easier on users, don't use zero or capital 'O', for example)
   6: #
   7: # *Not* a completely security-conscious implementation, especially when 
   8: #   generating multiple passwords at once...
   9: #
  10: # Change @Chars to suit your preference
  11: # Change the inner for loop to determine password length
  12: # 
  13: # Usage: $0 [Number of passwords to generate]
  14: 
  15: my @Chars = split '',
  16:         'abcdefghijkmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789@#$%&*=+_<>?~';
  17: 
  18: for (1..($ARGV[0] ||= 1)){
  19:   my $Password;
  20:   for (1..6){ 
  21:     $Password .= $Chars[rand @Chars];
  22:   }
  23:   print "$Password\n";
  24: }

Replies are listed 'Best First'.
RE: Another Password Generator
by merlyn (Sage) on May 07, 2000 at 03:50 UTC
      Yeah, that was a response to another suggestion I received before posting here. The feeling was to be clear about:
      1) This is an integer (for the index into @Chars)
      2) "What, exactly, does rand() do to an array argument?" Convert it to a scalar expression, of course, but the idea was for increased clarity...

      Thanks for the comment, it helps to hear learned opinions on the correct balance between idiom (succinctness) and explicitness (ease-of-grokking by the less experienced)

      Russ