App-wordlist
view release on metacpan or search on metacpan
lib/App/wordlist.pm view on Meta::CPAN
}
sub _word_has_chars_ordered {
my ($word, $chars, $ci) = @_;
if ($ci) {
$word = lc $word;
$chars = lc $chars;
}
my $last_index;
for my $i (0..length($chars)-1) {
my $char = substr($chars, $i, 1);
my $index = index($word, $char);
return 0 if $index < 0;
return 0 if defined $last_index && $index < $last_index;
$last_index = $index;
$word =~ s/\Q$char\E//;
}
1;
}
$SPEC{wordlist} = {
v => 1.1,
summary => 'Grep words from (or test them against) WordList::*',
args => {
arg => {
schema => ['array*' => of => 'str*'],
pos => 0,
greedy => 1,
tags => ['category:word-filtering'],
},
ignore_case => {
schema => 'bool',
default => 1,
cmdline_aliases => {i=>{}},
tags => ['category:word-filtering'],
},
len => {
schema => 'int*',
tags => ['category:word-filtering'],
},
min_len => {
schema => 'int*',
tags => ['category:word-filtering'],
},
max_len => {
schema => 'int*',
tags => ['category:word-filtering'],
},
num => {
summary => 'Return (at most) this number of words (0 = unlimited)',
schema => ['int*', min=>0, max=>9999],
default => 0,
cmdline_aliases => {n=>{}},
},
random => {
summary => 'Pick random words',
description => <<'_',
If set to true, then streaming will be turned off. All words will be gathered
first, then words will be chosen randomly from the gathered list.
_
schema => 'bool*',
cmdline_aliases => {r=>{}},
},
%argspecopt_wordlists,
%argspecopt_wordlist_bundles,
%argspecsopt_exclude_wordlist,
or => {
summary => 'Instead of printing words that must match all queries (the default), print words that match any query',
schema => 'bool',
tags => ['category:word-filtering'],
},
action => {
schema => ['str*', {
in=>[
'list_cpan',
'list_installed',
'list_selected',
'grep',
'stat',
'test',
],
'x.in.summaries' => [
'List WordList::* modules on CPAN',
'List WordList::* modules installed locally',
'List WordList::* that are selected for use',
'Grep words from selected WordList::* modules',
'Show statistics for each selected WordList::* modules',
'Test words against selected WordList::* modules',
],
}],
default => 'grep',
cmdline_aliases => {
l => {
summary=>'List installed WordList::* modules',
is_flag => 1,
code => sub { my $args=shift; $args->{action} = 'list_installed' },
},
L => {
summary=>'List WordList::* modules on CPAN',
is_flag => 1,
code => sub { my $args=shift; $args->{action} = 'list_cpan' },
},
s => {
summary=>'Show statistics contained in the wordlist modules',
is_flag => 1,
code => sub { my $args=shift; $args->{action} = 'stat' },
},
t => {
summary=>'Test whether words exists in wordlist',
is_flag => 1,
code => sub { my $args=shift; $args->{action} = 'test' },
},
},
description => <<'_',
lib/App/wordlist.pm view on Meta::CPAN
Display more information when listing modulesE<sol>result.
When listing installed modules (C<-l>), this means also returning a wordlist's
language.
When returning grep result, this means also returning wordlist name.
=item * B<exclude_dynamic_wordlists> => I<bool>
(No description)
=item * B<exclude_wordlist_pattern> => I<re_from_str>
(No description)
=item * B<exclude_wordlists> => I<array[str]>
Exclude wordlist modules.
=item * B<ignore_case> => I<bool> (default: 1)
(No description)
=item * B<langs> => I<array[str]>
Only include wordlists of certain language(s).
By convention, language code is the first subnamespace of a wordlist module,
e.g. WordList::EN::* for English, WordList::FR::* for French, and so on.
Wordlist modules which do not follow this convention (e.g. WordList::Password::*
or WordList::PersonName::*) are not included.
=item * B<lcpan> => I<bool>
Use local CPAN mirror first when available (for -L).
=item * B<len> => I<int>
(No description)
=item * B<max_len> => I<int>
(No description)
=item * B<min_len> => I<int>
(No description)
=item * B<num> => I<int> (default: 0)
Return (at most) this number of words (0 = unlimited).
=item * B<or> => I<bool>
Instead of printing words that must match all queries (the default), print words that match any query.
=item * B<random> => I<bool>
Pick random words.
If set to true, then streaming will be turned off. All words will be gathered
first, then words will be chosen randomly from the gathered list.
=item * B<wordlist_bundles> => I<array[str]>
Select one or more wordlist bundle (Acme::CPANModules::WordListBundle::*) modules.
=item * B<wordlists> => I<array[str]>
Select one or more wordlist modules.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.
Return value: (any)
=head1 ENVIRONMENT
=head2 DEBUG => bool
=head2 COLOR => bool
Set color on/off when --color=auto (the default).
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/App-wordlist>.
=head1 SOURCE
Source repository is at L<https://github.com/perlancar/perl-App-wordlist>.
=head1 SEE ALSO
L<App::WordListUtils>
L<App::GamesWordlist> (L<games-wordlist>) which greps from
C<Games::Word::Wordlist::*> instead.
L<WordList> and C<WordList::*> modules.
L<arraydata> from L<App::arraydata>, L<hashdata> from L<App::hashdata>, and
L<tabledata> from L<App::tabledata>. These are newer projects that will
supersede WordList one day.
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 CONTRIBUTOR
=for stopwords Ryo
( run in 0.576 second using v1.01-cache-2.11-cpan-140bd7fdf52 )