The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::wordlist - Grep words from WordList::*

VERSION

This document describes version 0.271 of App::wordlist (from Perl distribution App-wordlist), released on 2020-05-21.

SYNOPSIS

See the included script wordlist.

FUNCTIONS

wordlist

Usage:

 wordlist(%args) -> [status, msg, payload, meta]

Grep words from WordList::*.

Examples:

  • By default print all words from all wordlists:

     wordlist();
  • Print all words matching /foo/ and /bar/:

     wordlist( arg => ["foo", "bar"]);
  • Print all words matching /foo/ or /bar/:

     wordlist( arg => ["foo", "bar"], or => 1);
  • Print wordlist name for each matching words:

     wordlist( arg => ["foo"], detail => 1);
  • Select a specific wordlist (multiple -w allowed):

     wordlist( arg => ["foo"], wordlists => ["ID::KBBI"]);
  • Select all ID::* wordlists (wildcard will be expanded):

     wordlist( arg => ["foo"], wordlists => ["ID::**"]);
  • Select French wordlists (multiple --lang allowed):

     wordlist( arg => ["foo"], langs => ["FR"]);
  • Filter by regex:

     wordlist( arg => ["/fof[aeiou]/"]);
  • List installed wordlist modules:

     wordlist( action => "list_installed");
  • List wordlist modules available on CPAN:

     wordlist( action => "list_cpan");

This function is not exported.

Arguments ('*' denotes required arguments):

  • action => str (default: "grep")

  • arg => array[str]

  • color => str (default: "auto")

    When to highlight search string/matching pattern with color.

  • detail => bool

    Display more information when listing modules/result.

    When listing installed modules (-l), this means also returning a wordlist's language.

    When returning grep result, this means also returning wordlist name.

  • ignore_case => bool (default: 1)

  • langs => 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.

  • lcpan => bool

    Use local CPAN mirror first when available (for -L).

  • len => int

  • max_len => int

  • min_len => int

  • num => int (default: 0)

    Return (at most) this number of words (0 = unlimited).

  • or => bool

    Match any word in query instead of the default "all".

  • random => 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.

  • wordlists => array[str]

    Select one or more wordlist modules.

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

FAQ

How to make wordlist return words in random order?

The --random (-r) option was removed in v0.268. To return random words, you can pipe the output of wordlist to shuf or other similar utility.

ENVIRONMENT

DEBUG => bool

COLOR => bool

Set color on/off when --color=auto (the default).

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-wordlist.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-wordlist.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-wordlist

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

App::GamesWordlist (games-wordlist) which greps from Games::Word::Wordlist::* instead.

WordList and WordList::* modules.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020, 2018, 2017, 2016, 2015, 2014 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.