--- a/pwgen.pl Fri Oct 03 15:05:36 2014 +0200
+++ b/pwgen.pl Wed Dec 09 15:44:05 2020 +0100
@@ -1,11 +1,30 @@
#!/usr/bin/perl
-# $Id$
+# $Id: pwgen.pl,v 72a196c63f31 2020/12/09 14:24:36 grin $
# (c)Peter Gervai, 2002; Released under GPLv2 + CC_BY-SA-2.0
#
-# jelszogenerator, 2002/04/08
+# jelszogenerator, 2002/04/08; 2016/11/09; 2020/12/09
#
-if( $ARGV[0] =~ /shutup/i ) { $shutup = 1; $num=1; } else { $num = 6; }
+use Getopt::Long;
+
+my $help;
+my $words=5;
+my $syllab=4;
+my $dash;
+my $dashlen=2;
+my $dashchr='-';
+my $longsyl=20;
+
+GetOptions(
+ "help" => \&help,
+ "words=i" => \$words,
+ "syllab=i" => \$syllab,
+ "dash" => \$dash,
+ "dashlen=i" => \$dashlen,
+ "longsyl=i" => \$longsyl,
+ "dashchr=s" => \$dashchr,
+) or &help;
+
$vowel='aeiou';
#$cons='bcdfghjklmnpqrstvwxyz';
@@ -14,23 +33,31 @@
$vlen=length($vowel);
$clen=length($cons);
-
$longsyl=20; # percent
-$sylnum=4 + rand(3);
-print "$num tok jo jelszo: " unless $shutup;
-
-
-
-for (1..$num) {
+for (1..$words) {
+ my $dash_count=0;
+ my $sylnum=$syllab + rand(3);
for my $i (1..$sylnum) {
print substr($cons,rand($clen),1);
print substr($vowel,rand($vlen),1);
print substr($cons,rand($clen),1) if $longsyl > rand(100);
- #print "-";
+ print $dashchr unless !$dash or ++$dash_count % $dashlen or $i>$sylnum-$dashlen;
}
- print " " unless $shutup;
+ print " ";
}
print "\n";
-print "\n" unless $shutup;
+
+
+sub help {
+ print "Usage:\n";
+ print " $0 [--help] [--words=$words] [--syllab=$syllab] [--longsyl=$longsyl] [--dash [--dashchr=$dashchr] [--dashlen=$dashlen]]\n";
+ print " words: how many passwords to display\n";
+ print " syllab: how many syllables in a word\n";
+ print " dash: use dash between syllables\n";
+ print " dashlen: use dash between every N syllable\n";
+ print " longsyl: long syllable probability (percent)\n";
+ print " dashchr: character to use instead of '-'\n";
+ exit;
+}