NAME
cfbase32-rand - Generate one or more Crockford Base 32 numbers
VERSION
This document describes version 0.002 of cfbase32-rand (from Perl distribution App-CrockfordBase32Utils), released on 2026-01-19.
SYNOPSIS
cfbase32-rand --help (or -h, -?)
cfbase32-rand --version (or -v)
cfbase32-rand [--debug|--log-level=level|--quiet|--trace|--verbose] [--format=name|--json] [--len=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-nums-file=filename] [--unique|--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)
- --prev-nums-file=s
-
(No description)
- --unique
-
Whether to avoid generating previously generated numbers.
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 towarn, which means that log statements with levelinfoand less important levels will not be shown. To increase verbosity, chooseinfo,debug, ortrace.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
- --format=s
-
Choose output format, e.g. json, text.
Default value:
undefOutput 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:
0By 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-resso 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.
lessis chosen. - --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
Range options
- --len=s
-
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
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 5 random numbers from 12 digits each, first digit(s) can be 0
% cfbase32-rand --len 12 -n35
ZKKN9WBGHA31
GX7H1RG0ZX0Q
4V36SNFSQ3NW
PFZVT6SRR1K3
233VVNHQF897
CA7QZ2VN4WJ3
R97GRD6WDQTA
8T86D2DEWDZ1
ZXQXJ26T1RHK
QK2TENPJ8SK0
TE9NE71JTC1S
2V589A34NXN8
6R0F75KGPGWD
QFVH5N9TK5SD
636HC301W30Y
XF248VA8TQJ8
H15SJT1BW6AD
MYQWR9WAK4R6
CPK4J1SFSA0E
X0P0E6CGFC3T
DKW4D9EWP0CV
Z52MR4VAZC89
92KW1NHBTKE4
TPM2ZDKHAH4P
4B5EBKKDMJP9
NXHW8PG4K0M7
Z57F5E2F1894
2W856WCCBHRF
31DPYPBHBC2D
69N5TKTG2S96
XZBRXF5P6T4V
DNPHYVKXN4BA
DT60CGNMM212
SAB88EN10A8B
5TWZPRKQQGQV
Generate 5 random numbers from 12 digits each, first digit(s) CANNOT be 0
% cfbase32-rand --len 12 -n35 --nozero-prefix
E914VFA8WW56
TZBZ34GG4J19
EWE2T0D5ZY3Z
RKBN8PGBGYME
TRHW278RMCPM
5GNQ8NS48ZQW
RSH6B22ZNMT0
YCNZSMNPFD71
7N6GG752XYM5
AVSPBCTKC46H
5205CFVKWK8H
S2VY1HBJHXCA
HEGYRPSFBM71
TDK0T5KJJB48
J201GZDFYSTW
VHSNP7MFSXXT
DQ293Z3889V1
MQ4R0SWFAMQW
N54Q6T2G0M03
VKWK513EQAZS
P5ZZ5SG04AY5
FT6ZMH677T48
QP75RKPH4ST1
WA9JR9GJSQ3Y
3ZD0Q47PBBXN
THVSE6J69QZP
XC3R0GCT4HEZ
6138MGRDN8ZN
6YJ946W2355R
TV1DKXHCMC5X
QXDGAMJMF7BA
5HYG8A2300ZK
S6P6FQ0GPRF8
W7W1S1Y60JW8
Q4KTBS770JMF
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.