start using builtin share function
parent
0bb5cb204d
commit
d3858175e1
|
@ -1,31 +1,26 @@
|
|||
package DDG::Goodie::Passphrase;
|
||||
|
||||
use DDG::Goodie;
|
||||
use File::ShareDir::ProjectDistDir;
|
||||
use IO::All;
|
||||
|
||||
triggers start => "passphrase";
|
||||
zci answer_type => "passphrase";
|
||||
|
||||
handle query_parts => sub {
|
||||
my $count = @_;
|
||||
return unless $count == 3;
|
||||
my ( $word_count, $descriptor ) = @_[ 1, 2 ];
|
||||
return if $word_count < 1;
|
||||
|
||||
my $sharedir = dist_dir('DDG-GoodieBundle-OpenSourceDuckDuckGo');
|
||||
my @words = share('words.txt')->slurp;
|
||||
|
||||
my @words = io("$sharedir/passphrase/words.txt")->slurp;
|
||||
|
||||
my $output;
|
||||
for (my $count = 0; $count < $word_count; $count++) {
|
||||
my $output = "random passphrase: ";
|
||||
for (1..$word_count) {
|
||||
my $word = splice @words, (int(rand @words)), 1;
|
||||
$output .= "$word ";
|
||||
}
|
||||
# Remove the trailing space
|
||||
chop $output;
|
||||
$output =~ s/\n//g;
|
||||
return "random passphrase: $output";
|
||||
return;
|
||||
return $output;
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package DDG::Goodie::PrivateNetwork;
|
||||
|
||||
use DDG::Goodie;
|
||||
use File::ShareDir::ProjectDistDir;
|
||||
use IO::All;
|
||||
|
||||
triggers query_clean => qr/^private (?:network|ip)s?\s*(?:(?:ips?|addresse?s?))?$/i;
|
||||
|
||||
|
@ -11,8 +9,8 @@ zci is_cached => 1;
|
|||
zci answer_type => "private_network";
|
||||
|
||||
handle sub {
|
||||
scalar io(dist_dir('DDG-GoodieBundle-OpenSourceDuckDuckGo').'/privatenetwork/privatenetwork.txt')->slurp,
|
||||
html => scalar io(dist_dir('DDG-GoodieBundle-OpenSourceDuckDuckGo').'/privatenetwork/privatenetwork.html')->slurp
|
||||
scalar share('private_network.txt')->slurp,
|
||||
html => scalar share('private_network.html')->slurp;
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -11,8 +11,8 @@ zci is_cached => 1;
|
|||
zci answer_type => "public_dns";
|
||||
|
||||
handle sub {
|
||||
scalar io(dist_dir('DDG-GoodieBundle-OpenSourceDuckDuckGo').'/publicdns/publicdns.txt')->slurp,
|
||||
html => scalar io(dist_dir('DDG-GoodieBundle-OpenSourceDuckDuckGo').'/publicdns/publicdns.html')->slurp
|
||||
scalar share('publicdns.txt')->slurp,
|
||||
html => scalar share('publicdns.html')->slurp;
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue