First, like all non-standard Perl modules, you will need to install Crypt::GeneratePassword from CPAN, and then you can include it at the top of your Perl programs with the use statement:
use Crypt::GeneratePassword qw(word);You can then use the word function in your program:
$password = word(MINIMUM-LENGTH, MAXIMUM-LENGTH);Here is a sample program that will print a 12 character random readable password:
#!/usr/bin/perl -wAs an alternative, you can also create passwords that are much less readable, but contain more complex characters:
use Crypt::GeneratePassword qw(word);
$word = word(12, 12);
print "$word\n";
exit;
#!/usr/bin/perl -w
use Crypt::GeneratePassword qw(chars);
$word = chars(12, 12);
print "$word\n";
exit;
