pwgen.pl: option to skip LF at the end of the line
authorPeter Gervai <grin@grin.hu>
Wed, 09 Dec 2020 15:57:34 +0100
changeset 5 98bc7c6e581a
parent 4 414797051084
child 6 78c000fd2ee7
pwgen.pl: option to skip LF at the end of the line
pwgen.pl
--- a/pwgen.pl	Wed Dec 09 15:46:30 2020 +0100
+++ b/pwgen.pl	Wed Dec 09 15:57:34 2020 +0100
@@ -1,12 +1,8 @@
 #!/usr/bin/perl
-# $Id: pwgen.pl,v 72a196c63f31 2020/12/09 14:24:36 grin $
-#
-# (c)Peter Gervai, 2002-2020; Released under GPLv3+ + CC_BY-SA-4.0
+# $Id: pwgen.pl,v 1ad4c2066b77 2020/12/09 14:56:54 grin $
+# (c)Peter Gervai, 2002; Released under GPLv2 + CC_BY-SA-2.0
 #
-# Password generator, 2002/04/08; 2016/11/09; 2020/12/09
-#
-# This code generates easy (easier) to spell and remember passwords.
-# The length, in-dashes and plenty of stuff are configurable.
+# jelszogenerator, 2002/04/08; 2016/11/09; 2020/12/09
 #
 
 use Getopt::Long;
@@ -18,6 +14,7 @@
 my $dashlen=2;
 my $dashchr='-';
 my $longsyl=20;
+my $nolf=0;
 
 GetOptions(
   "help" 	=> \&help,
@@ -27,6 +24,7 @@
   "dashlen=i"	=> \$dashlen,
   "longsyl=i"	=> \$longsyl,
   "dashchr=s"	=> \$dashchr,
+  "nolf"	=> \$nolf,
 ) or &help;
 
 
@@ -48,10 +46,10 @@
         print substr($cons,rand($clen),1) if $longsyl > rand(100);
         print $dashchr  unless !$dash or ++$dash_count % $dashlen  or  $i>$sylnum-$dashlen;
     }
-    print "   ";
+    print "   " unless $words == 1;
 }
 
-print "\n";
+print "\n" unless $nolf;
 
 
 sub help {
@@ -63,5 +61,6 @@
     print "      dashlen: use dash between every N syllable\n";
     print "      longsyl: long syllable probability (percent)\n";
     print "      dashchr: character to use instead of '-'\n";
+    print "      nolf:    don't print a linefeed after the last word\n";
     exit;
 }