|
1 |
| -#!/usr/bin/perl -w |
2 |
| -use strict; |
3 |
| - |
4 |
| -# this program will read pw-new.dic, and list counts. You provide the max length of lines |
5 |
| -# that make up the input file, and then other shorter lengths, and this script will tell |
6 |
| -# how many passwords are of the shorter lengths. So, ./count_finder.pl 110 55 will list |
7 |
| -# 1500 for length 110, and then 1120 (or how even many it is) for length 55. |
8 |
| - |
9 |
| -if (scalar @ARGV > 4 || scalar @ARGV < 2) { die print "usage: ./count_finder.pl max_len shorter_len [count [pw file]]\n"; } |
10 |
| -my $count = 1500; |
11 |
| -my $pw_name = "pw-new.dic"; |
12 |
| -my $len = $ARGV[0]; |
13 |
| -my $short = $ARGV[1]; |
14 |
| -if ($len <= $short) { die print "error! shorter_len was not shorter\nusage: ./count_finder.pl max_len shorter_len [count [pw file]]\n"; } |
15 |
| -my $short_cnt = 0; |
16 |
| -if (scalar @ARGV > 2) {$count = $ARGV[2];} |
17 |
| -if (scalar @ARGV == 4) {$pw_name = $ARGV[3];} |
18 |
| -my $orig_count = $count; |
19 |
| -my $line_cnt = 0; |
20 |
| - |
21 |
| -open FILE, '<:encoding(UTF-8)', $pw_name or die "Can't open '$pw_name' for reading: $!"; |
22 |
| -my @words = <FILE>; |
23 |
| -close(FILE); |
24 |
| -foreach my $word (@words) { |
25 |
| - chomp $word; |
26 |
| - ++$line_cnt; |
27 |
| - if (length($word) <= $len) { |
28 |
| - $count--; |
29 |
| - if (length($word) <= $short) { $short_cnt++; } |
30 |
| - if ($count == 0) { |
31 |
| - print "Found $orig_count of length $len (required $line_cnt total lines to do)\n"; |
32 |
| - print "Found $short_cnt of length $short\n"; |
33 |
| - exit(0); |
34 |
| - } |
35 |
| - } |
36 |
| -} |
37 |
| -print "ran out of words, there were not $orig_count of length $len\n"; |
38 |
| -print "Found $orig_count-$count of length $len\n"; |
39 |
| -print "Found $short_cnt of length $short\n"; |
40 |
| - |
41 |
| - |
| 1 | +#!/usr/bin/perl -w |
| 2 | +use strict; |
| 3 | + |
| 4 | +# this program will read pw-new.dic, and list counts. You provide the max length of lines |
| 5 | +# that make up the input file, and then other shorter lengths, and this script will tell |
| 6 | +# how many passwords are of the shorter lengths. So, ./count_finder.pl 110 55 will list |
| 7 | +# 1500 for length 110, and then 1120 (or how even many it is) for length 55. |
| 8 | + |
| 9 | +if (scalar @ARGV > 4 || scalar @ARGV < 2) { die print "usage: ./count_finder.pl max_len shorter_len [count [pw file]]\n"; } |
| 10 | +my $count = 1500; |
| 11 | +my $pw_name = "pw-new.dic"; |
| 12 | +my $len = $ARGV[0]; |
| 13 | +my $short = $ARGV[1]; |
| 14 | +if ($len <= $short) { die print "error! shorter_len was not shorter\nusage: ./count_finder.pl max_len shorter_len [count [pw file]]\n"; } |
| 15 | +my $short_cnt = 0; |
| 16 | +if (scalar @ARGV > 2) {$count = $ARGV[2];} |
| 17 | +if (scalar @ARGV == 4) {$pw_name = $ARGV[3];} |
| 18 | +my $orig_count = $count; |
| 19 | +my $line_cnt = 0; |
| 20 | + |
| 21 | +open FILE, '<:encoding(UTF-8)', $pw_name or die "Can't open '$pw_name' for reading: $!"; |
| 22 | +my @words = <FILE>; |
| 23 | +close(FILE); |
| 24 | +foreach my $word (@words) { |
| 25 | + chomp $word; |
| 26 | + ++$line_cnt; |
| 27 | + if (length($word) <= $len) { |
| 28 | + $count--; |
| 29 | + if (length($word) <= $short) { $short_cnt++; } |
| 30 | + if ($count == 0) { |
| 31 | + print "Found $orig_count of length $len (required $line_cnt total lines to do)\n"; |
| 32 | + print "Found $short_cnt of length $short\n"; |
| 33 | + exit(0); |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | +print "ran out of words, there were not $orig_count of length $len\n"; |
| 38 | +print "Found $orig_count-$count of length $len\n"; |
| 39 | +print "Found $short_cnt of length $short\n"; |
| 40 | + |
| 41 | + |
0 commit comments