NAME

cfbase32-rand - Generate one or more Crockford Base 32 numbers

VERSION

This document describes version 0.003 of cfbase32-rand (from Perl distribution App-CrockfordBase32Utils), released on 2026-01-20.

SYNOPSIS

cfbase32-rand --help (or -h, -?)

cfbase32-rand --version (or -v)

cfbase32-rand [--debug|--log-level=level|--quiet|--trace|--verbose] [--fill-char-template=str|-f=str] [--format=name|--json] [--len=int|-l=int] [--max-base32=str] [--max-int=int] [--max-len=int] [--min-base32=str] [--min-int=int] [--min-len=int] [--(no)naked-res] [--num=uint|-n=uint] [--page-result[=program]|--view-result[=program]] [--prev-file=filename|-p=filename] [--unique|-u|--no-unique|--nounique] [--zero-prefix|--no-zero-prefix|--nozero-prefix]

See examples in the "EXAMPLES" section.

OPTIONS

* marks required options.

Main options

--no-zero-prefix

(No description)

Logging options

--debug

Shortcut for --log-level=debug.

--log-level=s

Set log level.

By default, these log levels are available (in order of increasing level of importance, from least important to most): trace, debug, info, warn/warning, error, fatal. By default, the level is usually set to warn, which means that log statements with level info and less important levels will not be shown. To increase verbosity, choose info, debug, or trace.

For more details on log level and logging, as well as how new logging levels can be defined or existing ones modified, see Log::ger.

--quiet

Shortcut for --log-level=error.

--trace

Shortcut for --log-level=trace.

--verbose

Shortcut for --log-level=info.

Output options

--fill-char-template=s, -f

Provide a template for formatting number, e.g. "###-###-###".

See String::FillCharTemplate for more details.

--format=s

Choose output format, e.g. json, text.

Default value:

undef

Output can be displayed in multiple formats, and a suitable default format is chosen depending on the application and/or whether output destination is interactive terminal (i.e. whether output is piped). This option specifically chooses an output format.

--json

Set output format to json.

--naked-res

When outputing as JSON, strip result envelope.

Default value:

0

By default, when outputing as JSON, the full enveloped result is returned, e.g.:

[200,"OK",[1,2,3],{"func.extra"=>4}]

The reason is so you can get the status (1st element), status message (2nd element) as well as result metadata/extra result (4th element) instead of just the result (3rd element). However, sometimes you want just the result, e.g. when you want to pipe the result for more post-processing. In this case you can use --naked-res so you just get:

[1,2,3]
--page-result

Filter output through a pager.

This option will pipe the output to a specified pager program. If pager program is not specified, a suitable default e.g. less is chosen.

--prev-file=s, -p

Load list of previous numbers from the specified file.

The file will be read per-line. Empty lines and lines starting with "#" will be skipped. Non-digits will be removed first. Lowercase will be converted to uppercase. I L will be normalized to 1, O will be normalized to 0.

--unique, -u

Whether to avoid generating previously generated numbers.

--view-result

View output using a viewer.

This option will first save the output to a temporary file, then open a viewer program to view the temporary file. If a viewer program is not chosen, a suitable default, e.g. the browser, is chosen.

Quantity options

--num=s, -n

Specify how many numbers to generate.

Default value:

1

Range options

--len=s, -l

Specify how many number of digits to generate for a number.

Note that the first digit can still be 0 unless zero_prefix is set to false.

--max-base32=s

(No description)

--max-int=s

(No description)

--max-len=s

Specify how many maximum number of digits to generate.

Note that the first digit can still be 0 unless zero_prefix is set to false.

--min-base32=s

(No description)

--min-int=s

(No description)

--min-len=s

Specify how many minimum number of digits to generate.

Note that the first digit can still be 0 unless zero_prefix is set to false.

Other options

--help, -h, -?

Display help message and exit.

--version, -v

Display program's version and exit.

COMPLETION

This script has shell tab completion capability with support for several shells.

bash

To activate bash completion for this script, put:

complete -C cfbase32-rand cfbase32-rand

in your bash startup (e.g. ~/.bashrc). 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 recommended, however, that you install modules using cpanm-shcompgen which can activate shell completion for scripts immediately.

tcsh

To activate tcsh completion for this script, put:

complete cfbase32-rand 'p/*/`cfbase32-rand`/'

in your tcsh startup (e.g. ~/.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 shcompgen (see above).

other shells

For fish and zsh, install shcompgen as described above.

EXAMPLES

Generate 35 random numbers from 12 digits each, first digit(s) can be 0

% cfbase32-rand --len 12 -n35
SZBB2SPQ70NW
PJPNTXWN6ZHH
HWJE0YZKH7XZ
N4J7QGGT7FES
891Z5RANA355
VPH5AWGZP00Q
KK3NFG13F76D
7HXCC5KNPEWK
2TN03TQWGHVR
XD6QWF9DZY33
MK3JKPPTZ1BK
3V81GFXFSTJH
YWV21CNW7K15
XNCS45C0VYJ5
AZ69Y55JV558
W0250FAH5GBM
CBT5Y77VXDTK
6ZRPJ7QT9A7B
7EJNDRBXCJAN
S15KYZ1W5PF9
WT9Q3BNHWHEJ
7BCB6R0VYBA9
PEQ50ZY7N9QS
5W3S4K4NSXC1
AM8HFA19YBBR
FJVQQQ6MX279
A367BJ1EWE2V
B15Z1S4PEFGA
29Q8J5D94NQX
0Q2CVZMM6W3R
N3XW3HAY3Q6R
57RD6N2DNYDY
GCAFDM59W2M2
DRR21S5MVVMP
T61KWK05RP4R

Generate 35 random numbers from 12 digits each, first digit(s) CANNOT be 0

% cfbase32-rand --len 12 -n35 --nozero-prefix
ESVKPY19Q495
AEBQXQP1HTJJ
YV5DXQ0RGFQ5
G59ZST9Y9HQW
A66NBZCHK8WG
SGBBGQXKY4MW
T6C9MSQXYQ91
T070Q3XVF5S8
MZAX0NJ9SCWC
CFN651N4YPA8
23GXKYF0FX51
35CWCETBMHN2
BXAQ34B6QM3Z
BV1VTFV28BEV
Z671RGH3HTZD
JB3T37FD02PG
XJ03NCTXC00H
JJSHERAYG8Q5
TN86N9CYNSGM
FYYZZMN2JQDW
GEDCBEPWJXBT
76SPRG7VRTAZ
31GK4HPQTBPE
T4NN2S27GAF7
K45K4A5BD4EX
M7EJCNFEPQ7Q
86TXJGTWZ8RT
K8H9RAFTXKJQ
SH36A4AVA1D3
G00TMHSV0VHY
3QBRFEE5RVFS
JRZVK1C9AHE1
DX4MXE7VZ182
1DJKF29EQQE2
W432M94A7AD2

Generate a formatted random code

% cfbase32-rand -f '###-###-###' -l9
XE7-NSE-VPX

HOMEPAGE

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

SOURCE

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

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by perlancar <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.

BUGS

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

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.