App-wordlist
view release on metacpan or search on metacpan
script/wordlist view on Meta::CPAN
defined($toc_line)
or die "Unexpected end of data section while reading TOC line #$i";
chomp($toc_line);
$toc_line =~ /\S/ or last;
$toc_line =~ /^([^,]+),(\d+),(\d+)(?:,(.*))?$/
or die "Invalid TOC line #$i in data section: $toc_line";
$toc{$1} = [$2, $3, $4];
}
my $pos = tell $fh;
$toc{$_}[0] += $pos for keys %toc;
# calculate the line number of data section
my $data_pos = tell(DATA);
seek DATA, 0, 0;
my $pos = 0;
while (1) {
my $line = <DATA>;
$pos += length($line);
$data_linepos++;
last if $pos >= $data_pos;
}
seek DATA, $data_pos, 0;
\%toc;
};
if ($toc->{$_[1]}) {
warn "[datapacker] $_[1] FOUND in packed modules\n" if $debug;
seek DATA, $toc->{$_[1]}[0], 0;
read DATA, my($content), $toc->{$_[1]}[1];
my ($order, $lineoffset) = split(';', $toc->{$_[1]}[2]);
$content =~ s/^#//gm;
$content = "# line ".($data_linepos + $order+1 + $lineoffset)." \"".__FILE__."\"\n" . $content;
open my $fh, '<', \$content
or die "DataPacker error loading $_[1]: $!";
return $fh;
} else {
warn "[datapacker] $_[1] NOT found in packed modules\n" if $debug;
}
return;
}; # handler
unshift @INC, bless(sub {"dummy"}, "main::_DataPacker");
}
# END DATAPACK CODE
package main;
use 5.010001;
use strict;
#use warnings;
# load modules
### declare global variables
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-03-07'; # DATE
our $DIST = 'App-wordlist'; # DIST
our $VERSION = '0.295'; # VERSION
my $_pci_metas = {""=>{args=>{action=>{cmdline_aliases=>{L=>{code=>sub{"DUMMY"},is_flag=>1,summary=>"List WordList::* modules on CPAN"},l=>{code=>sub{"DUMMY"},is_flag=>1,summary=>"List installed WordList::* modules"},s=>{code=>sub{"DUMMY"},is_flag=>1...
our $_pci_log_outputs = {};
our $_pci_meta_result_stream = 0;
our $_pci_meta_result_type;
our $_pci_meta_result_type_is_simple;
our $_pci_meta_skip_format = 0;
our $_pci_r = {naked_res=>0,read_config=>1,read_env=>1,subcommand_name=>""};
our %_pci_args;
### begin code_before_enable_logging
### end code_before_enable_logging
### enable logging
$_pci_log_outputs->{Screen} = { conf => { colorize_tags => 1, formatter => sub { "wordlist: " . $_[0] } } };
#### begin code_add_extra_log_outputs
#### end code_add_extra_log_outputs
require Log::ger::Output; Log::ger::Output->set("Composite", outputs => $_pci_log_outputs);
require Log::ger; Log::ger->import;
### begin code_after_enable_logging
### end code_after_enable_logging
### declare subroutines
sub _pci_err {
my $res = shift;
print STDERR "ERROR $res->[0]: $res->[1]\n";
exit $res->[0]-300;
}
sub _pci_json {
state $json = do {
if (eval { require JSON::XS; 1 }) { JSON::XS->new->canonical(1)->allow_nonref }
else { require JSON::PP; JSON::PP->new->canonical(1)->allow_nonref }
};
$json;
}
### begin code_before_parse_cmdline_options
### end code_before_parse_cmdline_options
### get arguments (from config file, env, command-line args
{
my %mentioned_args;
require Getopt::Long::EvenLess;
log_trace("Parsing command-line arguments ...");
my $go_spec1 = {
'config-path=s@' => sub { $_pci_r->{config_paths} //= []; push @{ $_pci_r->{config_paths} }, $_[1]; },
'config-profile=s' => sub { $_pci_r->{config_profile} = $_[1]; },
'debug' => sub { require Log::ger::Util; Log::ger::Util::set_level("debug"); $_pci_r->{log_level} = "debug"; },
'format=s' => sub { $_pci_r->{format} = $_[1]; },
'help|h|?' => sub { print "wordlist - Grep words from (or test them against) WordList::*\n\nUsage:\n wordlist --help (or -h, -?)\n wordlist --version (or -v)\n wordlist [--action=str|-L|-l|-s|-t] [--chars-ordered=str]\n [--chars-unordered=s...
'json' => sub { $_pci_r->{format} = (-t STDOUT) ? "json-pretty" : "json"; ## no critic InputOutput::ProhibitInteractiveTest
},
'log-level=s' => sub { if ($_[1] eq "trace") { require Log::ger::Util; Log::ger::Util::set_level("trace"); Log::ger::Output::Composite::set_level("trace") } if ($_[1] eq "debug") { require Log::ger::Util; Log::ger::Util::set_level("debug"); Log::...
'naked-res' => sub { $_pci_r->{naked_res} = 1; },
'no-config' => sub { $_pci_r->{read_config} = 0; },
'no-env' => sub { $_pci_r->{read_env} = 0; },
'no-naked-res|nonaked-res' => sub { $_pci_r->{naked_res} = 0; },
'page-result:s' => sub { $_pci_r->{page_result} = 1; },
'quiet' => sub { require Log::ger::Util; Log::ger::Util::set_level("error"); $_pci_r->{log_level} = "error"; },
'trace' => sub { require Log::ger::Util; Log::ger::Util::set_level("trace"); $_pci_r->{log_level} = "trace"; },
script/wordlist view on Meta::CPAN
To activate tcsh completion for this script, put:
complete wordlist 'p/*/`wordlist`/'
in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.
It is also recommended to install L<shcompgen> (see above).
=head2 other shells
For fish and zsh, install L<shcompgen> as described above.
=head1 FAQ
=head2 How to select multiple wordlists? It's cumbersome having to -w WORDLIST1 -w WORDLIST2 and so on!
You can specify wildcard in C<-w> option, e.g. if you want to include all English
wordlists you can use C<-w EN::*> or C<-w EN::**> (C<**> recurses while C<*> only
matches one level deep).
Or you can also use C<-b> option. Some people bundle wordlists together and put
them up on CPAN in the C<Acme::CPANModules::WordListBundle::*> namespace. You can
install those modules first then use the wordlist bundle.
=head2 Can C<wordlist> help me solve Wordle?
Yes, using regex or the C<--chars-ordered> and C<--chars-unordered> options. For
example, if you have:
T W _ S _
(3 letters with the correct position), you can use:
% wordlist -w EN::Wordle '/^tw.s./' --len 5
twist
or:
% wordlist -w EN::Wordle --chars-ordered tws --len 5
tawse
thaws
...
twist
twits
Another example, if you have:
W* T* _ S _
(2 letters with the incorrect position and 1 letter in the correct position),
you can use:
% wordlist -w EN::Wordle --chars-unordered wts --len 5 '/^...s.$/'
Included in the distribution is the L<wordlist-wordle> script for
convenience. This CLI defaults to grepping the "EN::Wordle" wordlist and you
specify something like C<wt_S_> for the pattern (lowercase for letter in
incorrect position, uppercase for letter in correct position, underscore for
unguessed):
% wordlist-wordle 'wt_S_'
=head1 CONFIGURATION FILE
This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.
By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F<~/.config/wordlist.conf>, F<~/wordlist.conf>, or F</etc/wordlist.conf>.
All found files will be read and merged.
To disable searching for configuration files, pass C<--no-config>.
You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.
You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...
You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...
To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:
[plugin=DumpArgs]
-event=before_validate_args
-prio=99
[plugin=Foo]
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
action (see --action)
arg (see --arg)
chars_ordered (see --chars-ordered)
chars_unordered (see --chars-unordered)
color (see --color)
detail (see --detail)
exclude_dynamic_wordlists (see --exclude-dynamic-wordlists)
exclude_wordlist_pattern (see --exclude-wordlist-pattern)
exclude_wordlists (see --exclude-wordlist)
format (see --format)
ignore_case (see --no-ignore-case)
langs (see --lang)
lcpan (see --lcpan)
len (see --len)
log_level (see --log-level)
max_len (see --max-len)
min_len (see --min-len)
naked_res (see --naked-res)
num (see --num)
or (see --or)
random (see --random)
wordlist_bundles (see --wordlist-bundle)
wordlists (see --wordlist)
script/wordlist view on Meta::CPAN
# summary => 'Check some passwords against all Password wordlists except Password::RockYou (because it is slow to check)',
# test => 0,
# 'x.doc.show_result' => 0,
# tags => ['category:action-test'],
# },
# {
# argv => [qw/-w Password::** -P RockYou -t foobar 123456 someGoodPass923/],
# summary => 'Check some passwords against all Password wordlists except those matching /RockYou/ regex',
# test => 0,
# 'x.doc.show_result' => 0,
# tags => ['category:action-test'],
# },
# ],
# 'cmdline.default_format' => 'text-simple',
# 'x.doc.faq' => <<'_',
#
### How to select multiple wordlists? It's cumbersome having to -w WORDLIST1 -w WORDLIST2 and so on!
#
#You can specify wildcard in `-w` option, e.g. if you want to include all English
#wordlists you can use `-w EN::*` or `-w EN::**` (`**` recurses while `*` only
#matches one level deep).
#
#Or you can also use `-b` option. Some people bundle wordlists together and put
#them up on CPAN in the `Acme::CPANModules::WordListBundle::*` namespace. You can
#install those modules first then use the wordlist bundle.
#
### Can `wordlist` help me solve Wordle?
#
#Yes, using regex or the `--chars-ordered` and `--chars-unordered` options. For
#example, if you have:
#
# T W _ S _
#
#(3 letters with the correct position), you can use:
#
# % wordlist -w EN::Wordle '/^tw.s./' --len 5
# twist
#
#or:
#
# % wordlist -w EN::Wordle --chars-ordered tws --len 5
# tawse
# thaws
# ...
# twist
# twits
#
#Another example, if you have:
#
# W* T* _ S _
#
#(2 letters with the incorrect position and 1 letter in the correct position),
#you can use:
#
# % wordlist -w EN::Wordle --chars-unordered wts --len 5 '/^...s.$/'
#
#Included in the distribution is the <prog:wordlist-wordle> script for
#convenience. This CLI defaults to grepping the "EN::Wordle" wordlist and you
#specify something like `wt_S_` for the pattern (lowercase for letter in
#incorrect position, uppercase for letter in correct position, underscore for
#unguessed):
#
# % wordlist-wordle 'wt_S_'
#
#_
#};
#sub wordlist {
# require Encode;
# require Module::Load::Util;
#
# my %args = @_;
#
# my $action = $args{action} // 'grep';
# my $list_installed = _list_installed();
# my $ci = $args{ignore_case} // 1;
# my $or = $args{or};
# my $arg = $args{arg} // [];
# my $detail = $args{detail};
# my $num = $args{num} // 0;
# my $random = $args{random};
# my $color = $args{color} // 'auto';
#
# my $use_color = ($color eq 'always' ? 1 : $color eq 'never' ? 0 : undef)
# // $ENV{COLOR} // (-t STDOUT);
#
# if ($action eq 'grep' || $action eq 'stat' || $action eq 'list_selected' || $action eq 'test') {
# # convert /.../ in arg to regex
# for (@$arg) {
# $_ = Encode::decode('UTF-8', $_);
# if (m!\A/(.*)/\z!) {
# $_ = $ci ? qr/$1/i : qr/$1/;
# } else {
# $_ = lc($_) if $ci;
# }
# }
#
# my @res;
# my $wordlists = [];
# my $has_specified_list;
#
# if ($args{wordlist_bundles}) {
# $has_specified_list++;
# for my $wb (@{ $args{wordlist_bundles} }) {
# my $wbmod = "Acme::CPANModules::WordListBundle::$wb";
# (my $wbmodpm = "$wbmod.pm") =~ s!::!/!g;
# require $wbmodpm;
#
# my $list;
# {
# no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
# $list = ${"$wbmod\::LIST"};
# }
#
# my $i = -1;
# for my $entry (@{ $list->{entries} }) {
# $i++;
# my $mod = $entry->{module};
# $mod =~ s/\AWordList::// or do {
# warn "Wordlist bundle module $wbmod: entry[$i]: module is not WordList::, skipped";
# next;
# };
( run in 2.709 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )