removed call to system grep, loaded list into hash; cleaned up list
parent
aed36f5065
commit
b23b3c2609
|
@ -1,25 +1,20 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $q_check_lc = 'passphrase 4 words';
|
||||
my $q_check_lc = "passphrase $ARGV[$1] words";
|
||||
my $answer_results = '';
|
||||
my $answer_type = 'passphrase';
|
||||
|
||||
if ( $q_check_lc =~ m/^passphrase ([1-9]) word|words$/ ) {
|
||||
|
||||
sub word_for_num {
|
||||
# use grep because the file is pretty large
|
||||
my $match = shift;
|
||||
my $result = `grep $match list.txt`;
|
||||
# don't include the reference number in the passphrase
|
||||
$result = substr($result, 6, length($result));
|
||||
#remove the newline from the end of the grep result
|
||||
chomp($result);
|
||||
# add so there's a space between passphrase words
|
||||
$result .= " ";
|
||||
return sub { "$result" }
|
||||
if ($q_check_lc =~ m/^passphrase ([1-9]+) word|words$/) {
|
||||
open(IN, 'list.txt');
|
||||
my %shows = ();
|
||||
while (my $line = <IN>) {
|
||||
chomp($line);
|
||||
my @res = split(/ /, $line);
|
||||
$shows{lc $res[0]} = $res[1];
|
||||
|
||||
}
|
||||
close(IN);
|
||||
|
||||
for (my $count = 0; $count < int($1); $count++) {
|
||||
my $ref_num = '';
|
||||
|
@ -27,13 +22,11 @@ if ( $q_check_lc =~ m/^passphrase ([1-9]) word|words$/ ) {
|
|||
# alea iacta est!!!
|
||||
$ref_num .= int(rand(6)) + 1;
|
||||
}
|
||||
$answer_results .= word_for_num($ref_num)->();
|
||||
}
|
||||
|
||||
# remove the trailing space from the results.
|
||||
# There is a space added to the last word by $result .= " " in word_for_num
|
||||
$answer_results =~ s/\s+$//;
|
||||
$answer_type = 'passphrase';
|
||||
$answer_results .= "$shows{$ref_num} ";
|
||||
}
|
||||
}
|
||||
|
||||
# Remove the trailing space
|
||||
chop $answer_results;
|
||||
print qq($answer_type\t$answer_results\n);
|
||||
|
|
|
@ -1341,7 +1341,7 @@
|
|||
21223 cobol
|
||||
21224 cobra
|
||||
21225 coca
|
||||
21226 cock
|
||||
21226 cockatrice
|
||||
21231 cockle
|
||||
21232 cocky
|
||||
21233 coco
|
||||
|
@ -3634,7 +3634,7 @@
|
|||
35564 lab
|
||||
35565 laban
|
||||
35566 label
|
||||
35611 labia
|
||||
35611 labor
|
||||
35612 labile
|
||||
35613 lac
|
||||
35614 lace
|
||||
|
@ -5731,8 +5731,8 @@
|
|||
53421 severe
|
||||
53422 sew
|
||||
53423 sewn
|
||||
53424 sex
|
||||
53425 sexy
|
||||
53424 sewing
|
||||
53425 sewer
|
||||
53426 sf
|
||||
53431 sg
|
||||
53432 sh
|
||||
|
|
Loading…
Reference in New Issue