String-Random-0.32/0000755000076400007640000000000014120030057014006 5ustar shlomifshlomifString-Random-0.32/README.md0000644000076400007640000000010514120030057015261 0ustar shlomifshlomif[String-Random](https://metacpan.org/release/String-Random) on CPAN. String-Random-0.32/Changes0000644000076400007640000000713614120030057015310 0ustar shlomifshlomifRevision history for Perl extension String::Random: 0.32 2021-09-14 - Add ->get_pattern and ->set_pattern. - https://github.com/shlomif/String-Random/pull/5 - Thanks to https://github.com/ology 0.31 2020-10-17 - dist.ini / weaver.ini / .tidyallrc / etc. cleanup - Move to @SHLOMIF - Inspired by Lady_Aleena. 0.30 2018-05-22 - Convert to Dist-Zilla. 0.29 2015-12-24 - Add a dependency on the 'parent' module: - This caused some CPAN Testers failures on perl-5.8.x. - http://www.cpantesters.org/cpan/report/d21f0078-6c11-1014-b233-6b3058476d35 0.28 2015-01-22 - Convert Changes to CPAN::Changes and add t/cpan-changes.t . 0.27 2015-01-22 - Cache parsed range patterns. - Pull Request from Kosuke Asami (co-me). Thanks! - https://github.com/shlomif/String-Random/pull/1 - Clean up the code according to perlcritic. - Pull Request from Lance Brown. Thanks! - https://github.com/shlomif/String-Random/pull/2 - Add rand_gen parameter to new to specify a custom random generator. - Pull Request from Lance Brown. Thanks! - https://github.com/shlomif/String-Random/pull/3 0.26 2014-01-31 - LICENSE section and file (CPANTS). - Minimum version of perl in Build.PL / META.yml . 0.25 2013-12-27 - Update the link to the version control repository. 0.24 2013-12-03 - Add keywords and a link to he repository to Build.PL / META.yml. 0.23 2013-12-03 - Add t/style-trailing-space.t . - Update the POD in lib/String/Random.pm . - Add t/pod.t . - Convert Build.PL to Test::Run::Builder. - Hopefully fix https://rt.cpan.org/Public/Bug/Display.html?id=86894 - Bug #86894 for String-Random: Spurious warnings 0.22 2006-09-21 - Fix README to reflect current reality. - Random cleanup in this file. - Since we've broken compatibility with *really* old Perl5 anyway, modernize a bit more ("our" instead of "use vars"). Also explicitly require 5.6.1. 0.21 2006-04-20 - Modify test.pl to use Test::More. - Build with Module::Build. - Minor whitespace cleanup. - Avoid undefined results from randregex() and randpattern(). - Turn on warnings in the module. 0.20 2003-09-29 - Added support for *, +, and ? in regular expressions. 0.1992 2002-07-25 - Added support for {n,m} ranges in regular expressions. - Cleaned up the initialization of @punct. 0.1991 2002-02-28 - Added a "b" for random binary data in randpattern(). 0.199 2002-02-26 - fixed randregex() and randpattern() to Do The Right Thing(TM) when called in an array or scalar context, and when passed multiple arguments. (* WARNING * This is an incompatible change. Code expecting the behavior of earlier versions may break. Of course, the documentation warned that this change would be made, and everybody reads documentation, right? :-) - fixed use of $_ in randpattern(). (Unfortunately, there's still one use of $_ in a grep(), but I don't see how that can be avoided, and it only happens once on initialization.) 0.198 2000-05-16 - fixed \W generating "_" - reorganized a bit to make it easier to add more patterns - added \s and \S - added two-character literals (\t, \n, \r, \f, \a, \e) 0.197 1999-07-10 - moved most of randregex() to %regch - added random_regex() function interface 0.195 1999-07-07 - regex support is (at least mostly) complete 0.19 1999-07-04 - first pass of regex support 0.1 1998-09-10 - original version String-Random-0.32/LICENSE0000644000076400007640000005013114120030057015013 0ustar shlomifshlomifTerms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" ---------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End String-Random-0.32/inc/0000755000076400007640000000000014120030057014557 5ustar shlomifshlomifString-Random-0.32/inc/Test/0000755000076400007640000000000014120030057015476 5ustar shlomifshlomifString-Random-0.32/inc/Test/Run/0000755000076400007640000000000014120030057016242 5ustar shlomifshlomifString-Random-0.32/inc/Test/Run/Builder.pm0000644000076400007640000000336014120030057020170 0ustar shlomifshlomifpackage Test::Run::Builder; use strict; use warnings; use Module::Build; use vars qw(@ISA); @ISA = (qw(Module::Build)); sub ACTION_runtest { my ($self) = @_; my $p = $self->{properties}; $self->depends_on('code'); local @INC = @INC; # Make sure we test the module in blib/ unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')); $self->do_test_run_tests; } sub ACTION_distruntest { my ($self) = @_; $self->depends_on('distdir'); my $start_dir = $self->cwd; my $dist_dir = $self->dist_dir; chdir $dist_dir or die "Cannot chdir to $dist_dir: $!"; # XXX could be different names for scripts $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile or die "Error executing 'Build.PL' in dist directory: $!"; $self->run_perl_script('Build') or die "Error executing 'Build' in dist directory: $!"; $self->run_perl_script('Build', [], ['runtest']) or die "Error executing 'Build test' in dist directory"; chdir $start_dir; } sub do_test_run_tests { my $self = shift; require Test::Run::CmdLine::Iface; my $test_run = Test::Run::CmdLine::Iface->new( { 'test_files' => [glob("t/*.t")], } # 'backend_params' => $self->_get_backend_params(), ); return $test_run->run(); } sub ACTION_tags { my $self = shift; return $self->do_system( "ctags", qw(-f tags --recurse --totals --exclude=blib/** --exclude=t/lib/** --exclude=**/.svn/** --exclude='*~'), "--exclude=".$self->dist_name()."-*/**", qw(--languages=Perl --langmap=Perl:+.t) ); } 1; String-Random-0.32/META.yml0000644000076400007640000002633614120030057015271 0ustar shlomifshlomif--- abstract: 'Perl module to generate random strings based on a pattern' author: - 'Shlomi Fish ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Module::Build: '0.28' Test::More: '0.88' vars: '0' configure_requires: Module::Build: '0.28' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010' keywords: - generate - random - regex - regexp - regular-expression - string license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: String-Random provides: String::Random: file: lib/String/Random.pm version: '0.32' requires: Carp: '0' Exporter: '0' parent: '0' perl: 5.006_001 strict: '0' warnings: '0' resources: bugtracker: https://github.com/shlomif/string-random/issues homepage: http://metacpan.org/release/String-Random repository: http://github.com/shlomif/String-Random version: '0.32' x_Dist_Zilla: perl: version: '5.032001' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@Filter/TestMoreDoneTesting' version: '6.024' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@Filter/AutoPrereqs' version: '6.024' - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/ExecDir' version: '6.024' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Filter/GatherDir' version: '6.024' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/ManifestSkip' version: '6.024' - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/MetaYAML' version: '6.024' - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/PruneCruft' version: '6.024' - class: Dist::Zilla::Plugin::Readme name: '@Filter/Readme' version: '6.024' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/ShareDir' version: '6.024' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: '@Filter/CheckChangesHasContent' version: '0.011' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/ConfirmRelease' version: '6.024' - class: Dist::Zilla::Plugin::Manifest name: '@Filter/Manifest' version: '6.024' - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: '6.024' - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: '6.024' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.024' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: '1' inherit_version: '1' meta_noindex: '1' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Filter/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::MetaResources name: '@Filter/MetaResources' version: '6.024' - class: Dist::Zilla::Plugin::ModuleBuild config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/ModuleBuild' version: '6.024' - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: '6.024' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Filter/PodCoverageTests' version: '6.024' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: '6.024' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Filter/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::Test::CPAN::Changes config: Dist::Zilla::Plugin::Test::CPAN::Changes: changelog: Changes name: '@Filter/Test::CPAN::Changes' version: '0.012' - class: Dist::Zilla::Plugin::Test::EOL config: Dist::Zilla::Plugin::Test::EOL: filename: xt/author/eol.t finder: - ':ExecFiles' - ':InstallModules' - ':TestFiles' trailing_whitespace: 1 name: '@Filter/Test::EOL' version: '0.19' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@Filter/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::TrailingSpace name: '@Filter/Test::TrailingSpace' version: ~ - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/TestRelease' version: '6.024' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::SingleEncoding name: '@SHLOMIF/SingleEncoding' version: '4.018' - class: Pod::Weaver::Plugin::WikiDoc name: '@SHLOMIF/WikiDoc' version: '0.093004' - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.018' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Name' version: '4.018' - class: Pod::Weaver::Section::Version name: '@SHLOMIF/Version' version: '4.018' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/Prelude' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Synopsis' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Description' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Usage' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Overview' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Stability' version: '4.018' - class: Pod::Weaver::Section::Collect name: Requirements version: '4.018' - class: Pod::Weaver::Section::Collect name: Attributes version: '4.018' - class: Pod::Weaver::Section::Collect name: Constructors version: '4.018' - class: Pod::Weaver::Section::Collect name: Methods version: '4.018' - class: Pod::Weaver::Section::Collect name: Functions version: '4.018' - class: Pod::Weaver::Section::Leftovers name: '@SHLOMIF/Leftovers' version: '4.018' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/postlude' version: '4.018' - class: Pod::Weaver::Section::Support name: '@SHLOMIF/Support' version: '1.013' - class: Pod::Weaver::Section::Authors name: '@SHLOMIF/Authors' version: '4.018' - class: Pod::Weaver::Section::Bugs name: '@SHLOMIF/Bugs' version: '4.018' - class: Pod::Weaver::Section::Contributors name: '@SHLOMIF/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@SHLOMIF/Legal' version: '4.018' - class: Pod::Weaver::Plugin::Transformer name: '@SHLOMIF/List' version: '4.018' name: '@Filter/PodWeaver' version: '4.009' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/UploadToCPAN' version: '6.024' - class: Dist::Zilla::Plugin::Keywords config: Dist::Zilla::Plugin::Keywords: keywords: - generate - random - regex - regexp - regular-expression - string name: Keywords version: '0.007' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.024' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.024' x_generated_by_perl: v5.32.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' String-Random-0.32/dist.ini0000644000076400007640000000061414120030057015453 0ustar shlomifshlomifname = String-Random version = 0.32 author = Shlomi Fish license = Perl_5 copyright_holder = Shlomi Fish [@Filter] -bundle = @SHLOMIF -remove = License -remove = MakeMaker dist = String-Random repository_url = http://github.com/shlomif/String-Random [Keywords] keyword = generate keyword = random keyword = regex keyword = regexp keyword = regular-expression keyword = string String-Random-0.32/README0000644000076400007640000000060614120030057014670 0ustar shlomifshlomifThis archive contains the distribution String-Random, version 0.32: Perl module to generate random strings based on a pattern This software is copyright (c) 2021 by Shlomi Fish. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.024. String-Random-0.32/t/0000755000076400007640000000000014120030057014251 5ustar shlomifshlomifString-Random-0.32/t/03_random_string.t0000644000076400007640000000075614120030057017616 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => 4; # 1: Make sure we can load the module BEGIN { use_ok('String::Random', ':all'); } # 2: Make sure we can create a new object my $foo=new String::Random; ok(defined($foo), "new()"); # 3: Test function interface to randpattern() my $abc=random_string("012", ['a'], ['b'], ['c']); is($abc, 'abc', "random_string()"); # 4: Make sure the function didn't pollute $foo ok(!defined($foo->{'0'}), "pollute object"); # vi: set ai et syntax=perl: String-Random-0.32/t/02_new.t0000644000076400007640000000040214120030057015524 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => 2; # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Make sure we can create a new object my $foo=new String::Random; ok(defined($foo), "new()"); # vi: set ai et syntax=perl: String-Random-0.32/t/00-compile.t0000644000076400007640000000263614120030057016312 0ustar shlomifshlomifuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'String/Random.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; String-Random-0.32/t/06_random_regex.t0000644000076400007640000000247514120030057017425 0ustar shlomifshlomifuse strict; use warnings; use vars qw(@patterns); BEGIN { @patterns=( '\d\d\d', '\w\w\w', '[ABC][abc]', '[012][345]', '...', '[a-z][0-9]', '[aw-zX][123]', '[a-z]{5}', '0{80}', '[a-f][nprt]\d{3}', '\t\n\r\f\a\e', '\S\S\S', '\s\s\s', '\w{5,10}', '\w?', '\w+', '\w*', '', ); } use Test::More tests => (3 * @patterns + 3); # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Test function interface to randregex() is(String::Random::random_regex("[a][b][c]"), "abc", "random_regex()"); # Test regex support for (@patterns) { my $ret=String::Random::random_regex($_); ok($ret =~ /^$_$/, "random_regex('$_')") or diag "'$_' failed, '$ret' does not match.\n"; } # Test random_regex, this time passing an array. my @ret=String::Random::random_regex(@patterns); is(@ret, @patterns, "random_regex() return") or diag "random_regex() returned a different array size!"; for (my $n=0;$n<@patterns;$n++) { ok(defined($ret[$n]), "defined random_regex('$patterns[$n]')"); ok($ret[$n] =~ /^$patterns[$n]$/, "random_regex('$patterns[$n]')") or diag "'$patterns[$n]' failed, '$ret[$n]' does not match.\n"; } # vi: set ai et syntax=perl: String-Random-0.32/t/07_rand_gen.t0000644000076400007640000000153014120030057016520 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => (6); # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Make sure we can create a new object with rand_gen argument my $foo = String::Random->new( rand_gen => sub { my ($max) = @_; return int( $max - 1 ); } ); ok( defined($foo), "new()" ); # 3: Make sure _rand is defined ok( defined( $foo->{'_rand'} ), "_rand defined" ); # 4: Make sure _rand returns value as expected is( $foo->{'_rand'}(10), 9 ) or diag "_rand function returned wrong value"; # 5: check randpattern with rand_gen function my $cCn = $foo->randpattern("cCn"); is( $cCn, 'zZ9', "randpattern() with rand_gen" ); # 6: check randregex with rand_gen function $cCn = $foo->randregex("[a-z][A-Z][0-9]"); is( $cCn, 'zZ9', "randregex() with rand_gen" ); # vi: set ai et syntax=perl: String-Random-0.32/t/05_randregex.t0000644000076400007640000000240414120030057016721 0ustar shlomifshlomifuse strict; use warnings; use vars qw(@patterns); BEGIN { @patterns=( '\d\d\d', '\w\w\w', '[ABC][abc]', '[012][345]', '...', '[a-z][0-9]', '[aw-zX][123]', '[a-z]{5}', '0{80}', '[a-f][nprt]\d{3}', '\t\n\r\f\a\e', '\S\S\S', '\s\s\s', '\w{5,10}', '\w?', '\w+', '\w*', '', ); } use Test::More tests => (3 * @patterns + 3); # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Make sure we can create a new object my $foo=new String::Random; ok(defined($foo), "new()"); # Test regex support for (@patterns) { my $ret=$foo->randregex($_); ok($ret =~ /^$_$/, "randregex('$_')") or diag "'$_' failed, '$ret' does not match.\n"; } # Test regex support, but this time pass an array. my @ret=$foo->randregex(@patterns); is(@ret, @patterns, "randregex() return") or diag "randregex() returned a different array size!"; for (my $n=0;$n<@patterns;$n++) { ok(defined($ret[$n]), "defined randregex('$patterns[$n]')"); ok($ret[$n] =~ /^$patterns[$n]$/, "randregex('$patterns[$n]')") or diag "'$patterns[$n]' failed, '$ret[$n]' does not match.\n"; } # vi: set ai et syntax=perl: String-Random-0.32/t/04_randpattern.t0000644000076400007640000000306514120030057017267 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => 37; # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Make sure we can create a new object my $foo=new String::Random; my $bar=String::Random->new(); ok(defined($foo) && defined($bar), "new()"); # 3: Empty pattern shouldn't give undef for result ok(my @notempty=$foo->randpattern(''), "randpattern('')"); # Try the object method... $foo->{'x'}=['a']; $foo->{'y'}=['b']; $foo->{'z'}=['c']; # 4: passing a scalar, in a scalar context my $abc=$foo->randpattern("xyz"); is($abc, 'abc', "randpattern()"); # 5: passing an array, in a scalar context my @foo=qw(x y z); $abc=$foo->randpattern(@foo); is($abc, 'abc', "randpattern() (scalar)"); # 6-8: passing an array, in an array context my @bar=$foo->randpattern(@foo); for (my $n=0;$n<@foo;$n++) { is($bar[$n], $foo->{$foo[$n]}->[0], "randpattern() (array) ($n)"); } # 9-34: Check one of the built-in patterns to make # sure it contains what we think it should my @upcase=("A".."Z"); for (my $n=0;$n<26;$n++) { ok(defined($foo->{'C'}->[$n]) && ($upcase[$n] eq $foo->{'C'}->[$n]), "pattern ($n)"); } # 35: Test modifying one of the built-in patterns $foo->{'C'}=['n']; is($foo->randpattern("C"), "n", "modify patterns"); # 36: Make sure we haven't clobbered anything in an existing object isnt($bar->randpattern("C"), "n", "pollute pattern"); # 37: Make sure we haven't clobbered anything in a new object my $baz=new String::Random; ok(defined($baz) && ($baz->randpattern("C") ne "n"), "pollute new object"); # vi: set ai et syntax=perl: String-Random-0.32/t/01_use.t0000644000076400007640000000023714120030057015534 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => 1; # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # vi: set ai et syntax=perl: String-Random-0.32/t/08_get_set.t0000644000076400007640000000320614120030057016400 0ustar shlomifshlomifuse strict; use warnings; use Test::More tests => 37; # 1: Make sure we can load the module BEGIN { use_ok('String::Random'); } # 2: Make sure we can create a new object my $foo=new String::Random; my $bar=String::Random->new(); ok(defined($foo) && defined($bar), "new()"); # 3: Empty pattern shouldn't give undef for result ok(my @notempty=$foo->randpattern(''), "randpattern('')"); # Try the object method... $foo->set_pattern('x', ['a']); $foo->set_pattern('y', ['b']); $foo->set_pattern('z', ['c']); # 4: passing a scalar, in a scalar context my $abc=$foo->randpattern("xyz"); is($abc, 'abc', "randpattern()"); # 5: passing an array, in a scalar context my @foo=qw(x y z); $abc=$foo->randpattern(@foo); is($abc, 'abc', "randpattern() (scalar)"); # 6-8: passing an array, in an array context my @bar=$foo->randpattern(@foo); for (my $n=0;$n<@foo;$n++) { is($bar[$n], $foo->get_pattern($foo[$n])->[0], "randpattern() (array) ($n)"); } # 9-34: Check one of the built-in patterns to make # sure it contains what we think it should my @upcase=("A".."Z"); for (my $n=0;$n<26;$n++) { ok(defined($foo->get_pattern('C')->[$n]) && ($upcase[$n] eq $foo->get_pattern('C')->[$n]), "pattern ($n)"); } # 35: Test modifying one of the built-in patterns $foo->set_pattern('C', ['n']); is($foo->randpattern("C"), "n", "modify patterns"); # 36: Make sure we haven't clobbered anything in an existing object isnt($bar->randpattern("C"), "n", "pollute pattern"); # 37: Make sure we haven't clobbered anything in a new object my $baz=new String::Random; ok(defined($baz) && ($baz->randpattern("C") ne "n"), "pollute new object"); # vi: set ai et syntax=perl: String-Random-0.32/lib/0000755000076400007640000000000014120030057014554 5ustar shlomifshlomifString-Random-0.32/lib/String/0000755000076400007640000000000014120030057016022 5ustar shlomifshlomifString-Random-0.32/lib/String/Random.pm0000644000076400007640000004363714120030057017615 0ustar shlomifshlomif# String::Random - Generates a random string from a pattern # Copyright (C) 1999-2006 Steven Pritchard # # This program is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # $Id: Random.pm,v 1.4 2006/09/21 17:34:07 steve Exp $ package String::Random; $String::Random::VERSION = '0.32'; require 5.006_001; use strict; use warnings; use Carp; use parent qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( &random_string &random_regex ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); # These are the various character sets. my @upper = ( 'A' .. 'Z' ); my @lower = ( 'a' .. 'z' ); my @digit = ( '0' .. '9' ); my @punct = map {chr} ( 33 .. 47, 58 .. 64, 91 .. 96, 123 .. 126 ); my @any = ( @upper, @lower, @digit, @punct ); my @salt = ( @upper, @lower, @digit, '.', '/' ); my @binary = map {chr} ( 0 .. 255 ); # What's important is how they relate to the pattern characters. # These are the old patterns for randpattern/random_string. my %old_patterns = ( 'C' => [@upper], 'c' => [@lower], 'n' => [@digit], '!' => [@punct], '.' => [@any], 's' => [@salt], 'b' => [@binary], ); # These are the regex-based patterns. my %patterns = ( # These are the regex-equivalents. '.' => [@any], '\d' => [@digit], '\D' => [ @upper, @lower, @punct ], '\w' => [ @upper, @lower, @digit, '_' ], '\W' => [ grep { $_ ne '_' } @punct ], '\s' => [ q{ }, "\t" ], # Would anything else make sense? '\S' => [ @upper, @lower, @digit, @punct ], # These are translated to their double quoted equivalents. '\t' => ["\t"], '\n' => ["\n"], '\r' => ["\r"], '\f' => ["\f"], '\a' => ["\a"], '\e' => ["\e"], ); # This is used for cache of parsed range patterns in %regch my %parsed_range_patterns = (); # These characters are treated specially in randregex(). my %regch = ( '\\' => sub { my ( $self, $ch, $chars, $string ) = @_; if ( @{$chars} ) { my $tmp = shift( @{$chars} ); if ( $tmp eq 'x' ) { # This is supposed to be a number in hex, so # there had better be at least 2 characters left. $tmp = shift( @{$chars} ) . shift( @{$chars} ); push( @{$string}, [ chr( hex($tmp) ) ] ); } elsif ( $tmp =~ /[0-7]/ ) { carp 'octal parsing not implemented. treating literally.'; push( @{$string}, [$tmp] ); } elsif ( defined( $patterns{"\\$tmp"} ) ) { $ch .= $tmp; push( @{$string}, $patterns{$ch} ); } else { if ( $tmp =~ /\w/ ) { carp "'\\$tmp' being treated as literal '$tmp'"; } push( @{$string}, [$tmp] ); } } else { croak 'regex not terminated'; } }, '.' => sub { my ( $self, $ch, $chars, $string ) = @_; push( @{$string}, $patterns{$ch} ); }, '[' => sub { my ( $self, $ch, $chars, $string ) = @_; my @tmp; while ( defined( $ch = shift( @{$chars} ) ) && ( $ch ne ']' ) ) { if ( ( $ch eq '-' ) && @{$chars} && @tmp ) { my $begin_ch = $tmp[-1]; $ch = shift( @{$chars} ); my $key = "$begin_ch-$ch"; if ( defined( $parsed_range_patterns{$key} ) ) { push( @tmp, @{ $parsed_range_patterns{$key} } ); } else { my @chs; for my $n ( ( ord($begin_ch) + 1 ) .. ord($ch) ) { push @chs, chr($n); } $parsed_range_patterns{$key} = \@chs; push @tmp, @chs; } } else { carp "'$ch' will be treated literally inside []" if ( $ch =~ /\W/ ); push( @tmp, $ch ); } } croak 'unmatched []' if ( $ch ne ']' ); push( @{$string}, \@tmp ); }, '*' => sub { my ( $self, $ch, $chars, $string ) = @_; unshift( @{$chars}, split( //, '{0,}' ) ); }, '+' => sub { my ( $self, $ch, $chars, $string ) = @_; unshift( @{$chars}, split( //, '{1,}' ) ); }, '?' => sub { my ( $self, $ch, $chars, $string ) = @_; unshift( @{$chars}, split( //, '{0,1}' ) ); }, '{' => sub { my ( $self, $ch, $chars, $string ) = @_; my $closed; CLOSED: for my $c ( @{$chars} ) { if ( $c eq '}' ) { $closed = 1; last CLOSED; } } if ($closed) { my $tmp; while ( defined( $ch = shift( @{$chars} ) ) && ( $ch ne '}' ) ) { croak "'$ch' inside {} not supported" if ( $ch !~ /[\d,]/ ); $tmp .= $ch; } if ( $tmp =~ /,/ ) { if ( my ( $min, $max ) = $tmp =~ /^(\d*),(\d*)$/ ) { if ( !length($min) ) { $min = 0 } if ( !length($max) ) { $max = $self->{'_max'} } croak "bad range {$tmp}" if ( $min > $max ); if ( $min == $max ) { $tmp = $min; } else { $tmp = $min + $self->{'_rand'}( $max - $min + 1 ); } } else { croak "malformed range {$tmp}"; } } if ($tmp) { my $prev_ch = $string->[-1]; push @{$string}, ( ($prev_ch) x ( $tmp - 1 ) ); } else { pop( @{$string} ); } } else { # { isn't closed, so treat it literally. push( @{$string}, [$ch] ); } }, ); # Default rand function sub _rand { my ($max) = @_; return int rand $max; } sub new { my ( $proto, @args ) = @_; my $class = ref($proto) || $proto; my $self; $self = {%old_patterns}; # makes $self refer to a copy of %old_patterns my %args = (); if (@args) { %args = @args } if ( defined( $args{'max'} ) ) { $self->{'_max'} = $args{'max'}; } else { $self->{'_max'} = 10; } if ( defined( $args{'rand_gen'} ) ) { $self->{'_rand'} = $args{'rand_gen'}; } else { $self->{'_rand'} = \&_rand; } return bless( $self, $class ); } # Returns a random string for each regular expression given as an # argument, or the strings concatenated when used in a scalar context. sub randregex { my $self = shift; croak 'called without a reference' if ( !ref($self) ); my @strings = (); while ( defined( my $pattern = shift ) ) { my $ch; my @string = (); my $string = q{}; # Split the characters in the pattern # up into a list for easier parsing. my @chars = split( //, $pattern ); while ( defined( $ch = shift(@chars) ) ) { if ( defined( $regch{$ch} ) ) { $regch{$ch}->( $self, $ch, \@chars, \@string ); } elsif ( $ch =~ /[\$\^\*\(\)\+\{\}\]\|\?]/ ) { # At least some of these probably should have special meaning. carp "'$ch' not implemented. treating literally."; push( @string, [$ch] ); } else { push( @string, [$ch] ); } } foreach my $ch (@string) { $string .= $ch->[ $self->{'_rand'}( scalar( @{$ch} ) ) ]; } push( @strings, $string ); } return wantarray ? @strings : join( q{}, @strings ); } # For compatibility with an ancient version, please ignore... sub from_pattern { my ( $self, @args ) = @_; croak 'called without a reference' if ( !ref($self) ); return $self->randpattern(@args); } sub randpattern { my $self = shift; croak 'called without a reference' if ( !ref($self) ); my @strings = (); while ( defined( my $pattern = shift ) ) { my $string = q{}; for my $ch ( split( //, $pattern ) ) { if ( defined( $self->{$ch} ) ) { $string .= $self->{$ch} ->[ $self->{'_rand'}( scalar( @{ $self->{$ch} } ) ) ]; } else { croak qq(Unknown pattern character "$ch"!); } } push( @strings, $string ); } return wantarray ? @strings : join( q{}, @strings ); } sub get_pattern { my ( $self, $name ) = @_; return $self->{ $name }; } sub set_pattern { my ( $self, $name, $charset ) = @_; $self->{ $name } = $charset; } sub random_regex { my (@args) = @_; my $foo = String::Random->new; return $foo->randregex(@args); } sub random_string { my ( $pattern, @list ) = @_; my $foo = String::Random->new; for my $n ( 0 .. $#list ) { $foo->{$n} = [ @{ $list[$n] } ]; } return $foo->randpattern($pattern); } 1; =pod =encoding UTF-8 =head1 NAME String::Random - Perl module to generate random strings based on a pattern =head1 VERSION version 0.32 =head1 SYNOPSIS use String::Random; my $string_gen = String::Random->new; print $string_gen->randregex('\d\d\d'); # Prints 3 random digits # Prints 3 random printable characters print $string_gen->randpattern("..."); I use String::Random qw(random_regex random_string); print random_regex('\d\d\d'); # Also prints 3 random digits print random_string("..."); # Also prints 3 random printable characters =head1 DESCRIPTION This module makes it trivial to generate random strings. As an example, let's say you are writing a script that needs to generate a random password for a user. The relevant code might look something like this: use String::Random; my $pass = String::Random->new; print "Your password is ", $pass->randpattern("CCcc!ccn"), "\n"; This would output something like this: Your password is UDwp$tj5 B: currently, C defaults to Perl's built-in predictable random number generator so the passwords generated by it are insecure. See the C option to C constructor to specify a more secure random number generator. There is no equivalent to this in the procedural interface, you must use the object-oriented interface to get this functionality. If you are more comfortable dealing with regular expressions, the following code would have a similar result: use String::Random; my $pass = String::Random->new; print "Your password is ", $pass->randregex('[A-Z]{2}[a-z]{2}.[a-z]{2}\d'), "\n"; =head2 Patterns The pre-defined patterns (for use with C and C) are as follows: c Any Latin lowercase character [a-z] C Any Latin uppercase character [A-Z] n Any digit [0-9] ! A punctuation character [~`!@$%^&*()-_+={}[]|\:;"'.<>?/#,] . Any of the above s A "salt" character [A-Za-z0-9./] b Any binary data These can be modified, but if you need a different pattern it is better to create another pattern, possibly using one of the pre-defined as a base. For example, if you wanted a pattern C that contained all upper and lower case letters (C<[A-Za-z]>), the following would work: my $gen = String::Random->new; $gen->{'A'} = [ 'A'..'Z', 'a'..'z' ]; I my $gen = String::Random->new; $gen->{'A'} = [ @{$gen->{'C'}}, @{$gen->{'c'}} ]; I my $gen = String::Random->new; $gen->set_pattern(A => [ 'A'..'Z', 'a'..'z' ]); The random_string function, described below, has an alternative interface for adding patterns. =head2 Methods =over 8 =item new =item new max =E I =item new rand_gen =E I Create a new String::Random object. Optionally a parameter C can be included to specify the maximum number of characters to return for C<*> and other regular expression patterns that do not return a fixed number of characters. Optionally a parameter C can be included to specify a subroutine coderef for generating the random numbers used in this module. The coderef must accept one argument C and return an integer between 0 and C. The default rand_gen coderef is sub { my ($max) = @_; return int rand $max; } =item randpattern LIST The randpattern method returns a random string based on the concatenation of all the pattern strings in the list. It will return a list of random strings corresponding to the pattern strings when used in list context. =item randregex LIST The randregex method returns a random string that will match the regular expression passed in the list argument. Please note that the arguments to randregex are not real regular expressions. Only a small subset of regular expression syntax is actually supported. So far, the following regular expression elements are supported: \w Alphanumeric + "_". \d Digits. \W Printable characters other than those in \w. \D Printable characters other than those in \d. . Printable characters. [] Character classes. {} Repetition. * Same as {0,}. ? Same as {0,1}. + Same as {1,}. Regular expression support is still somewhat incomplete. Currently special characters inside [] are not supported (with the exception of "-" to denote ranges of characters). The parser doesn't care for spaces in the "regular expression" either. =item get_pattern STRING Return a pattern given a name. my $gen = String::Random->new; $gen->get_pattern('C'); (Added in version 0.32.) =item set_pattern STRING ARRAYREF Add or redefine a pattern given a name and a character set. my $gen = String::Random->new; $gen->set_pattern(A => [ 'A'..'Z', 'a'..'z' ]); (Added in version 0.32.) =item from_pattern B - for compatibility with an old version. B =back =head2 Functions =over 8 =item random_string PATTERN,LIST =item random_string PATTERN When called with a single scalar argument, random_string returns a random string using that scalar as a pattern. Optionally, references to lists containing other patterns can be passed to the function. Those lists will be used for 0 through 9 in the pattern (meaning the maximum number of lists that can be passed is 10). For example, the following code: print random_string("0101", ["a", "b", "c"], ["d", "e", "f"]), "\n"; would print something like this: cebd =item random_regex REGEX_IN_STRING Prints a string for the regular expression given as the string. See the synposis for example. =back =head1 BUGS This is Bug Free™ code. (At least until somebody finds one…) Please report bugs here: L . =head1 AUTHOR Original Author: Steven Pritchard C<< steve@silug.org >> Now maintained by: Shlomi Fish ( L ). =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1). =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * MetaCPAN A modern, open-source CPAN search engine, useful to view POD in HTML format. L =item * RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. L =item * CPANTS The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. L =item * CPAN Testers The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. L =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L =back =head2 Bugs / Feature Requests Please report any bugs or feature requests by email to C, or through the web interface at L. You will be automatically notified of any progress on the request by the system. =head2 Source Code The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) L git clone http://github.com/shlomif/String-Random =head1 AUTHOR Shlomi Fish =head1 BUGS Please report any bugs or feature requests on the bugtracker website L 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. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2021 by Shlomi Fish. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # vi: set ai et: String-Random-0.32/Build.PL0000644000076400007640000000241614120030057015305 0ustar shlomifshlomif # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.024. use strict; use warnings; use Module::Build 0.28; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28" }, "configure_requires" => { "Module::Build" => "0.28" }, "dist_abstract" => "Perl module to generate random strings based on a pattern", "dist_author" => [ "Shlomi Fish " ], "dist_name" => "String-Random", "dist_version" => "0.32", "license" => "perl", "module_name" => "String::Random", "recursive_test_files" => 1, "requires" => { "Carp" => 0, "Exporter" => 0, "parent" => 0, "perl" => "5.006_001", "strict" => 0, "warnings" => 0 }, "test_requires" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.88", "vars" => 0 } ); my %fallback_build_requires = ( "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.28", "Test::More" => "0.88", "vars" => 0 ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; String-Random-0.32/MANIFEST.SKIP0000644000076400007640000000000314120030057015675 0ustar shlomifshlomif~$ String-Random-0.32/META.json0000644000076400007640000004344314120030057015437 0ustar shlomifshlomif{ "abstract" : "Perl module to generate random strings based on a pattern", "author" : [ "Shlomi Fish " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010", "keywords" : [ "generate", "random", "regex", "regexp", "regular-expression", "string" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "String-Random", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28" } }, "configure" : { "requires" : { "Module::Build" : "0.28" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::EOL" : "0", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::TrailingSpace" : "0.0203" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "parent" : "0", "perl" : "5.006_001", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.88", "vars" : "0" } } }, "provides" : { "String::Random" : { "file" : "lib/String/Random.pm", "version" : "0.32" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/shlomif/string-random/issues" }, "homepage" : "http://metacpan.org/release/String-Random", "repository" : { "type" : "git", "url" : "http://github.com/shlomif/String-Random", "web" : "https://github.com/shlomif/string-random" } }, "version" : "0.32", "x_Dist_Zilla" : { "perl" : { "version" : "5.032001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@Filter/TestMoreDoneTesting", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@Filter/AutoPrereqs", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/ExecDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Filter/GatherDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/ManifestSkip", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/MetaYAML", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/PruneCruft", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/Readme", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/ShareDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "@Filter/CheckChangesHasContent", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/ConfirmRelease", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/Manifest", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.024" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Filter/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@Filter/MetaResources", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ModuleBuild", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/ModuleBuild", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Filter/PodCoverageTests", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Filter/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "config" : { "Dist::Zilla::Plugin::Test::CPAN::Changes" : { "changelog" : "Changes" } }, "name" : "@Filter/Test::CPAN::Changes", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::Test::EOL", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/author/eol.t", "finder" : [ ":ExecFiles", ":InstallModules", ":TestFiles" ], "trailing_whitespace" : 1 } }, "name" : "@Filter/Test::EOL", "version" : "0.19" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@Filter/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::TrailingSpace", "name" : "@Filter/Test::TrailingSpace", "version" : null }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/TestRelease", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@SHLOMIF/SingleEncoding", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::WikiDoc", "name" : "@SHLOMIF/WikiDoc", "version" : "0.093004" }, { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Name", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@SHLOMIF/Version", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/Prelude", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Synopsis", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Description", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Usage", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Overview", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Stability", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Requirements", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Constructors", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@SHLOMIF/Leftovers", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/postlude", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Support", "name" : "@SHLOMIF/Support", "version" : "1.013" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@SHLOMIF/Authors", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Bugs", "name" : "@SHLOMIF/Bugs", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@SHLOMIF/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@SHLOMIF/Legal", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@SHLOMIF/List", "version" : "4.018" } ] } }, "name" : "@Filter/PodWeaver", "version" : "4.009" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/UploadToCPAN", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Keywords", "config" : { "Dist::Zilla::Plugin::Keywords" : { "keywords" : [ "generate", "random", "regex", "regexp", "regular-expression", "string" ] } }, "name" : "Keywords", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.024" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.024" } }, "x_generated_by_perl" : "v5.32.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.26", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } String-Random-0.32/MANIFEST0000644000076400007640000000100614120030057015134 0ustar shlomifshlomif# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.024. Build.PL Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml README README.md TODO dist.ini inc/Test/Run/Builder.pm lib/String/Random.pm t/00-compile.t t/01_use.t t/02_new.t t/03_random_string.t t/04_randpattern.t t/05_randregex.t t/06_random_regex.t t/07_rand_gen.t t/08_get_set.t weaver.ini xt/author/eol.t xt/author/no-tabs.t xt/author/pod-coverage.t xt/author/pod-syntax.t xt/release/cpan-changes.t xt/release/trailing-space.t String-Random-0.32/weaver.ini0000644000076400007640000000001314120030057015772 0ustar shlomifshlomif[@SHLOMIF] String-Random-0.32/xt/0000755000076400007640000000000014120030057014441 5ustar shlomifshlomifString-Random-0.32/xt/release/0000755000076400007640000000000014120030057016061 5ustar shlomifshlomifString-Random-0.32/xt/release/cpan-changes.t0000644000076400007640000000034414120030057020576 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; String-Random-0.32/xt/release/trailing-space.t0000644000076400007640000000103414120030057021146 0ustar shlomifshlomif#!perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); String-Random-0.32/xt/author/0000755000076400007640000000000014120030057015743 5ustar shlomifshlomifString-Random-0.32/xt/author/pod-syntax.t0000644000076400007640000000025214120030057020235 0ustar shlomifshlomif#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); String-Random-0.32/xt/author/no-tabs.t0000644000076400007640000000066314120030057017500 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/String/Random.pm', 't/00-compile.t', 't/01_use.t', 't/02_new.t', 't/03_random_string.t', 't/04_randpattern.t', 't/05_randregex.t', 't/06_random_regex.t', 't/07_rand_gen.t', 't/08_get_set.t' ); notabs_ok($_) foreach @files; done_testing; String-Random-0.32/xt/author/pod-coverage.t0000644000076400007640000000033414120030057020503 0ustar shlomifshlomif#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); String-Random-0.32/xt/author/eol.t0000644000076400007640000000071514120030057016712 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/String/Random.pm', 't/00-compile.t', 't/01_use.t', 't/02_new.t', 't/03_random_string.t', 't/04_randpattern.t', 't/05_randregex.t', 't/06_random_regex.t', 't/07_rand_gen.t', 't/08_get_set.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; String-Random-0.32/TODO0000644000076400007640000000067714120030057014510 0ustar shlomifshlomifFEATURES: * (foo|bar) should be doable. * Generally make some attempt to implement everything documented in perlre(1), or at least carp() that we aren't doing the right thing. * Allow . to mean binary data in regular expressions (maybe with a flag to new()). * Implement a way to over-ride the random function using a custom one. - This will allow platform-independent random number generators as well as Linux’s /dev/urandom / etc.