List-SomeUtils-0.56/0000775000175000017500000000000013134705504014145 5ustar autarchautarchList-SomeUtils-0.56/dist.ini0000644000175000017500000000130213134705504015603 0ustar autarchautarchname = List-SomeUtils author = Tassilo von Parseval author = Adam Kennedy author = Jens Rehsack author = Dave Rolsky license = Perl_5 copyright_holder = Dave Rolsky [@DROLSKY] dist = List-SomeUtils pod_coverage_skip = List::SomeUtils::PP stopwords_file = .stopwords use_github_issues = 1 -remove = Test::CleanNamespaces -remove = Test::Synopsis ;authordep ExtUtils::HasCompiler = 0.014 [Prereqs / DevelopRequires] Scalar::Util = 0 Storable = 0 Test::LeakTrace = 0 Tie::Array = 0 [DynamicPrereqs] :version = 0.029 -body = requires('List::SomeUtils::XS', '0.54') if !want_pp() and can_xs(); List-SomeUtils-0.56/META.yml0000644000175000017500000005764613134705504015436 0ustar autarchautarch--- abstract: 'Provide the stuff missing in List::Util' author: - 'Tassilo von Parseval ' - 'Adam Kennedy ' - 'Jens Rehsack ' - 'Dave Rolsky ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Scalar::Util: '0' Storable: '0' Test::Builder::Module: '0' Test::LeakTrace: '0' Test::More: '0.96' Tie::Array: '0' base: '0' lib: '0' overload: '0' configure_requires: ExtUtils::MakeMaker: '0' Text::ParseWords: '0' dynamic_config: 1 generated_by: 'Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: List-SomeUtils provides: List::SomeUtils: file: lib/List/SomeUtils.pm version: '0.56' List::SomeUtils::PP: file: lib/List/SomeUtils/PP.pm version: '0.56' requires: Carp: '0' Exporter: '0' List::Util: '0' Module::Implementation: '0' perl: '5.006' strict: '0' vars: '0' warnings: '0' resources: bugtracker: https://github.com/houseabsolute/List-SomeUtils/issues homepage: http://metacpan.org/release/List-SomeUtils repository: git://github.com/houseabsolute/List-SomeUtils.git version: '0.56' x_Dist_Zilla: perl: version: '5.024001' plugins: - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DROLSKY/MakeMaker' version: '6.010' - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - CONTRIBUTING.md - LICENSE - Makefile.PL - README.md - cpanfile exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@DROLSKY/Git::GatherDir' version: '2.042' - class: Dist::Zilla::Plugin::ManifestSkip name: '@DROLSKY/ManifestSkip' version: '6.010' - class: Dist::Zilla::Plugin::License name: '@DROLSKY/License' version: '6.010' - class: Dist::Zilla::Plugin::ExecDir name: '@DROLSKY/ExecDir' version: '6.010' - class: Dist::Zilla::Plugin::ShareDir name: '@DROLSKY/ShareDir' version: '6.010' - class: Dist::Zilla::Plugin::Manifest name: '@DROLSKY/Manifest' version: '6.010' - class: Dist::Zilla::Plugin::CheckVersionIncrement name: '@DROLSKY/CheckVersionIncrement' version: '0.121750' - class: Dist::Zilla::Plugin::TestRelease name: '@DROLSKY/TestRelease' version: '6.010' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@DROLSKY/ConfirmRelease' version: '6.010' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@DROLSKY/UploadToCPAN' version: '6.010' - class: Dist::Zilla::Plugin::VersionFromMainModule name: '@DROLSKY/VersionFromMainModule' version: '0.03' - class: Dist::Zilla::Plugin::Authority name: '@DROLSKY/Authority' version: '1.009' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@DROLSKY/AutoPrereqs' version: '6.010' - class: Dist::Zilla::Plugin::CopyFilesFromBuild name: '@DROLSKY/CopyFilesFromBuild' version: '0.170880' - class: Dist::Zilla::Plugin::GitHub::Meta name: '@DROLSKY/GitHub::Meta' version: '0.44' - class: Dist::Zilla::Plugin::GitHub::Update config: Dist::Zilla::Plugin::GitHub::Update: metacpan: 1 name: '@DROLSKY/GitHub::Update' version: '0.44' - class: Dist::Zilla::Plugin::MetaResources name: '@DROLSKY/MetaResources' version: '6.010' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.010' 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.000033' version: '0.004' name: '@DROLSKY/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::Meta::Contributors name: '@DROLSKY/Meta::Contributors' version: '0.003' - class: Dist::Zilla::Plugin::MetaConfig name: '@DROLSKY/MetaConfig' version: '6.010' - class: Dist::Zilla::Plugin::MetaJSON name: '@DROLSKY/MetaJSON' version: '6.010' - class: Dist::Zilla::Plugin::MetaYAML name: '@DROLSKY/MetaYAML' version: '6.010' - class: Dist::Zilla::Plugin::NextRelease name: '@DROLSKY/NextRelease' version: '6.010' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@DROLSKY/Test::More with subtest' version: '6.010' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@DROLSKY/Modules for use with tidyall' version: '6.010' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@DROLSKY/Test::Version which fixes https://github.com/plicease/Test-Version/issues/7' version: '6.010' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 0 check_all_prereqs: 0 modules: - Dist::Zilla::PluginBundle::DROLSKY phase: build run_under_travis: 0 skip: [] name: '@DROLSKY/Dist::Zilla::PluginBundle::DROLSKY' version: '0.053' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 1 modules: [] phase: release run_under_travis: 0 skip: - Dist::Zilla::Plugin::DROLSKY::Contributors - Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch - Dist::Zilla::Plugin::DROLSKY::License - Dist::Zilla::Plugin::DROLSKY::TidyAll - Dist::Zilla::Plugin::DROLSKY::WeaverConfig - Pod::Weaver::PluginBundle::DROLSKY name: '@DROLSKY/PromptIfStale' version: '0.053' - class: Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable name: '@DROLSKY/Test::Pod::Coverage::Configurable' version: '0.06' - class: Dist::Zilla::Plugin::Test::PodSpelling config: Dist::Zilla::Plugin::Test::PodSpelling: directories: - bin - lib spell_cmd: '' stopwords: - ARRAYn - ARRAYn - Anno - Anno - AnnoCPAN - AnnoCPAN - Branno - Branno - DROLSKY - "DROLSKY's" - EXPR - EXPR - Filmer - Filmer - Inkster - Jens - KEYFUNC - KEYFUNC - LMU - MULTICALL - MULTICALL - McCauley - McCauley - Muey - Muey - PRs - Parseval - PayPal - Purkis - Purkis - Rabbitson - Rabbitson - Rehsack - Rezic - Rezic - Rolsky - "Rolsky's" - Roode - Roode - Siegel - Siegel - Signes - Slaven - Slaven - Summersault - Summersault - TODO - TODO - Tassilo - Tatham - Tatham - Thegler - Thegler - bsearchidx - bsearchidx - de - drolsky - firstidx - firstidx - firstres - firstres - firstval - firstval - glitchy - glitchy - lastidx - lastidx - lastres - lastres - lastval - lastval - listify - listify - minmax - minmax - natatime - natatime - notall - notall - onlyidx - onlyidx - onlyres - onlyres - onlyval - onlyval - refactor - refactor - rehsackATcpan - thusly - thusly - uniq - uniq - von wordlist: Pod::Wordlist name: '@DROLSKY/Test::PodSpelling' version: '2.007004' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@DROLSKY/PodSyntaxTests' version: '6.010' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DROLSKY/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::MojibakeTests name: '@DROLSKY/MojibakeTests' version: '0.8' - class: Dist::Zilla::Plugin::Test::CPAN::Changes config: Dist::Zilla::Plugin::Test::CPAN::Changes: changelog: Changes name: '@DROLSKY/Test::CPAN::Changes' version: '0.012' - class: Dist::Zilla::Plugin::Test::CPAN::Meta::JSON name: '@DROLSKY/Test::CPAN::Meta::JSON' version: '0.004' - 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: '@DROLSKY/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: '@DROLSKY/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::Portability config: Dist::Zilla::Plugin::Test::Portability: options: '' name: '@DROLSKY/Test::Portability' version: '2.001000' - class: Dist::Zilla::Plugin::Test::TidyAll name: '@DROLSKY/Test::TidyAll' version: '0.04' - 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: xt/author/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: develop script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@DROLSKY/Test::Compile' version: '2.056' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@DROLSKY/Test::ReportPrereqs' version: '0.027' - class: Dist::Zilla::Plugin::Test::Version name: '@DROLSKY/Test::Version' version: '1.09' - class: Dist::Zilla::Plugin::DROLSKY::Contributors name: '@DROLSKY/DROLSKY::Contributors' version: '0.85' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: git_version: 2.7.4 include_authors: 0 include_releaser: 1 order_by: name paths: [] name: '@DROLSKY/Git::Contributors' version: '0.030' - class: Dist::Zilla::Plugin::SurgicalPodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@DROLSKY' finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.015' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.015' - class: Pod::Weaver::Plugin::SingleEncoding name: '@DROLSKY/SingleEncoding' version: '4.015' - class: Pod::Weaver::Plugin::Transformer name: '@DROLSKY/List' version: '4.015' - class: Pod::Weaver::Plugin::Transformer name: '@DROLSKY/Verbatim' version: '4.015' - class: Pod::Weaver::Section::Region name: '@DROLSKY/header' version: '4.015' - class: Pod::Weaver::Section::Name name: '@DROLSKY/Name' version: '4.015' - class: Pod::Weaver::Section::Version name: '@DROLSKY/Version' version: '4.015' - class: Pod::Weaver::Section::Region name: '@DROLSKY/prelude' version: '4.015' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.015' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.015' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.015' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.015' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.015' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.015' - class: Pod::Weaver::Section::Collect name: TYPES version: '4.015' - class: Pod::Weaver::Section::Leftovers name: '@DROLSKY/Leftovers' version: '4.015' - class: Pod::Weaver::Section::Region name: '@DROLSKY/postlude' version: '4.015' - class: Pod::Weaver::Section::GenerateSection name: '@DROLSKY/generate SUPPORT' version: '1.06' - class: Pod::Weaver::Section::AllowOverride name: '@DROLSKY/allow override SUPPORT' version: '0.05' - class: Pod::Weaver::Section::GenerateSection name: '@DROLSKY/generate SOURCE' version: '1.06' - class: Pod::Weaver::Section::GenerateSection name: '@DROLSKY/generate DONATIONS' version: '1.06' - class: Pod::Weaver::Section::Authors name: '@DROLSKY/Authors' version: '4.015' - class: Pod::Weaver::Section::Contributors name: '@DROLSKY/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@DROLSKY/Legal' version: '4.015' - class: Pod::Weaver::Section::Region name: '@DROLSKY/footer' version: '4.015' name: '@DROLSKY/SurgicalPodWeaver' version: '0.0023' - class: Dist::Zilla::Plugin::DROLSKY::WeaverConfig name: '@DROLSKY/DROLSKY::WeaverConfig' version: '0.85' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: '@DROLSKY/README.md in build' version: '0.163250' - class: Dist::Zilla::Plugin::GenerateFile::FromShareDir config: Dist::Zilla::Plugin::GenerateFile::FromShareDir: destination_filename: CONTRIBUTING.md dist: Dist-Zilla-PluginBundle-DROLSKY encoding: UTF-8 has_xs: '0' location: build source_filename: CONTRIBUTING.md Dist::Zilla::Role::RepoFileInjector: allow_overwrite: 1 repo_root: . version: '0.007' name: '@DROLSKY/Generate CONTRIBUTING.md' version: '0.013' - class: Dist::Zilla::Plugin::InstallGuide name: '@DROLSKY/InstallGuide' version: '1.200007' - class: Dist::Zilla::Plugin::CPANFile name: '@DROLSKY/CPANFile' version: '6.010' - class: Dist::Zilla::Plugin::DROLSKY::License name: '@DROLSKY/DROLSKY::License' version: '0.85' - class: Dist::Zilla::Plugin::CheckStrictVersion name: '@DROLSKY/CheckStrictVersion' version: '0.001' - class: Dist::Zilla::Plugin::CheckSelfDependency config: Dist::Zilla::Plugin::CheckSelfDependency: finder: - ':InstallModules' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000033' version: '0.004' name: '@DROLSKY/CheckSelfDependency' version: '0.011' - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@DROLSKY/CheckPrereqsIndexed' version: '0.020' - class: Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch config: Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . name: '@DROLSKY/DROLSKY::Git::CheckFor::CorrectBranch' version: '0.85' - class: Dist::Zilla::Plugin::EnsureChangesHasContent name: '@DROLSKY/EnsureChangesHasContent' version: '0.02' - class: Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts config: Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . name: '@DROLSKY/Git::CheckFor::MergeConflicts' version: '0.014' - class: Dist::Zilla::Plugin::DROLSKY::TidyAll name: '@DROLSKY/DROLSKY::TidyAll' version: '0.85' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - CONTRIBUTING.md - Changes - LICENSE - Makefile.PL - README.md - cpanfile - tidyall.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . name: '@DROLSKY/Git::Check' version: '2.042' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - CONTRIBUTING.md - Changes - LICENSE - Makefile.PL - README.md - cpanfile - tidyall.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/Commit generated files' version: '2.042' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: v0.56 tag_format: v%v tag_message: v%v Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/Git::Tag' version: '2.042' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . name: '@DROLSKY/Git::Push' version: '2.042' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 0 munge_makefile_pl: 1 name: '@DROLSKY/BumpVersionAfterRelease' version: '0.015' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'Bump version after release' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: - (?^:.+) changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/Commit version bump' version: '2.042' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: git_version: 2.7.4 repo_root: . name: '@DROLSKY/Push version bump' version: '2.042' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: DevelopRequires version: '6.010' - class: Dist::Zilla::Plugin::DynamicPrereqs config: Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000033' version: '0.004' name: DynamicPrereqs version: '0.033' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.010' - class: Dist::Zilla::Plugin::FinderCode name: '@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.010' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.010' x_authority: cpan:DROLSKY x_contributors: - 'Aaron Crane ' - 'BackPan ' - 'Brad Forschinger ' - 'David Golden ' - 'jddurand ' - 'Jens Rehsack ' - 'J.R. Mash ' - 'Karen Etheridge ' - 'Ricardo Signes ' - 'Toby Inkster ' - 'Tokuhiro Matsuno ' - 'Tom Wyant ' x_serialization_backend: 'YAML::Tiny version 1.70' List-SomeUtils-0.56/perltidyrc0000644000175000017500000000045513134705504016253 0ustar autarchautarch-l=78 -i=4 -ci=4 -se -b -bar -boc -vt=0 -vtc=0 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nolq -npro -nsfs --blank-lines-before-packages=0 --opening-hash-brace-right --no-outdent-long-comments --iterations=2 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" List-SomeUtils-0.56/t/0000775000175000017500000000000013134705504014410 5ustar autarchautarchList-SomeUtils-0.56/t/00-report-prereqs.t0000644000175000017500000001342613134705504020010 0ustar autarchautarch#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.027 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: List-SomeUtils-0.56/t/Import.t0000644000175000017500000000025713134705504016051 0ustar autarchautarchuse strict; use warnings; use lib 't/lib'; BEGIN { $ENV{LIST_SOMEUTILS_IMPLEMENTATION} = 'PP' } use Test::More 0.96; use LSU::Test::Import; LSU::Test::Import->run_tests; List-SomeUtils-0.56/t/ab.t0000644000175000017500000000022113134705504015150 0ustar autarchautarchuse strict; use warnings; use lib 't/lib'; BEGIN { $ENV{LIST_SOMEUTILS_IMPLEMENTATION} = 'PP' } use LSU::Test::ab; LSU::Test::ab->run_tests; List-SomeUtils-0.56/t/pp-only.t0000644000175000017500000000043413134705504016172 0ustar autarchautarch# PP only use strict; use warnings; use Test::More 0.96; BEGIN { $ENV{LIST_SOMEUTILS_IMPLEMENTATION} = 'PP' } use List::SomeUtils; is( Module::Implementation::implementation_for('List::SomeUtils'), 'PP', 'List::SomeUtils is using PP implementation' ); done_testing(); List-SomeUtils-0.56/t/00-report-prereqs.dd0000644000175000017500000000743313134705504020135 0ustar autarchautarchdo { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0', 'Text::ParseWords' => '0' } }, 'develop' => { 'requires' => { 'Code::TidyAll' => '0.56', 'Code::TidyAll::Plugin::SortLines::Naturally' => '0.000003', 'Code::TidyAll::Plugin::Test::Vars' => '0.02', 'ExtUtils::HasCompiler' => '0.014', 'File::Spec' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Parallel::ForkManager' => '1.19', 'Perl::Critic' => '1.126', 'Perl::Tidy' => '20160302', 'Pod::Coverage::TrustPod' => '0', 'Pod::Wordlist' => '0', 'Scalar::Util' => '0', 'Storable' => '0', 'Test::CPAN::Changes' => '0.19', 'Test::CPAN::Meta::JSON' => '0.16', 'Test::Code::TidyAll' => '0.50', 'Test::EOL' => '0', 'Test::LeakTrace' => '0', 'Test::Mojibake' => '0', 'Test::More' => '0.96', 'Test::NoTabs' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08', 'Test::Portability::Files' => '0', 'Test::Spelling' => '0.12', 'Test::Vars' => '0.009', 'Test::Version' => '2.05', 'Tie::Array' => '0', 'blib' => '1.01' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'Exporter' => '0', 'List::Util' => '0', 'Module::Implementation' => '0', 'perl' => '5.006', 'strict' => '0', 'vars' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Scalar::Util' => '0', 'Storable' => '0', 'Test::Builder::Module' => '0', 'Test::LeakTrace' => '0', 'Test::More' => '0.96', 'Tie::Array' => '0', 'base' => '0', 'lib' => '0', 'overload' => '0' } } }; $x; }List-SomeUtils-0.56/t/lib/0000775000175000017500000000000013134705504015156 5ustar autarchautarchList-SomeUtils-0.56/t/lib/LSU/0000775000175000017500000000000013134705504015621 5ustar autarchautarchList-SomeUtils-0.56/t/lib/LSU/Test/0000775000175000017500000000000013134705504016540 5ustar autarchautarchList-SomeUtils-0.56/t/lib/LSU/Test/Functions.pm0000644000175000017500000012632113134705504021051 0ustar autarchautarchpackage LSU::Test::Functions; use strict; use warnings; use Config; use List::SomeUtils ':all'; use Scalar::Util qw( weaken ); use Storable qw( freeze ); use Tie::Array (); use Test::More 0.96; use Test::LSU; # Run all tests sub run_tests { for my $export ( qw( any all none notall one any_u all_u none_u notall_u one_u true false firstidx lastidx onlyidx insert_after insert_after_string apply indexes before before_incl after after_incl firstval lastval onlyval firstres lastres onlyres each_array pairwise natatime zip mesh uniq singleton part minmax bsearch bsearchidx mode ) ) { my $sub = __PACKAGE__->can( 'test_' . $export ); subtest( $export, $sub ); } done_testing(); } ###################################################################### # Test code intentionally ignorant of implementation (Pure Perl or XS) # The any function should behave identically to # !! grep CODE LIST sub test_any_u { # Normal cases my @list = ( 1 .. 10000 ); is_true( any_u { $_ == 5000 } @list ); is_true( any_u { $_ == 5000 } 1 .. 10000 ); is_true( any_u {defined} @list ); is_false( any_u { not defined } @list ); is_true( any_u { not defined } undef ); is_undef( any_u {} ); leak_free_ok( any_u => sub { my $ok = any_u { $_ == 5000 } @list; my $ok2 = any_u { $_ == 5000 } 1 .. 10000; } ); leak_free_ok( 'any_u with a coderef that dies' => sub { # This test is from Kevin Ryde; see RT#48669 eval { my $ok = any_u {die} 1; }; } ); is_dying( sub { &any_u( 42, 4711 ); } ); } sub test_all_u { # Normal cases my @list = ( 1 .. 10000 ); is_true( all_u {defined} @list ); is_true( all_u { $_ > 0 } @list ); is_false( all_u { $_ < 5000 } @list ); is_undef( all_u {} ); leak_free_ok( all_u => sub { my $ok = all_u { $_ == 5000 } @list; my $ok2 = all_u { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &all_u( 42, 4711 ); } ); } sub test_none_u { # Normal cases my @list = ( 1 .. 10000 ); is_true( none_u { not defined } @list ); is_true( none_u { $_ > 10000 } @list ); is_false( none_u {defined} @list ); is_undef( none_u {} ); leak_free_ok( none_u => sub { my $ok = none_u { $_ == 5000 } @list; my $ok2 = none_u { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &none_u( 42, 4711 ); } ); } sub test_notall_u { # Normal cases my @list = ( 1 .. 10000 ); is_true( notall_u { !defined } @list ); is_true( notall_u { $_ < 10000 } @list ); is_false( notall_u { $_ <= 10000 } @list ); is_undef( notall_u {} ); leak_free_ok( notall_u => sub { my $ok = notall_u { $_ == 5000 } @list; my $ok2 = notall_u { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { ¬all_u( 42, 4711 ); } ); } sub test_one_u { # Normal cases my @list = ( 1 .. 300 ); is_true( one_u { 1 == $_ } @list ); is_true( one_u { 150 == $_ } @list ); is_true( one_u { 300 == $_ } @list ); is_false( one_u { 0 == $_ } @list ); is_false( one_u { 1 <= $_ } @list ); is_false( one_u { !( 127 & $_ ) } @list ); is_undef( one_u {} ); leak_free_ok( one => sub { my $ok = one_u { 150 <= $_ } @list; my $ok2 = one_u { 150 <= $_ } 1 .. 300; } ); is_dying( sub { &one_u( 42, 4711 ); } ); } sub test_true { # The null set should return zero my $null_scalar = true {}; my @null_list = true {}; is( $null_scalar, 0, 'true(null) returns undef' ); is_deeply( \@null_list, [0], 'true(null) returns undef' ); # Normal cases my @list = ( 1 .. 10000 ); is( 10000, true {defined} @list ); is( 0, true { not defined } @list ); is( 1, true { $_ == 5000 } @list ); leak_free_ok( true => sub { my $n = true { $_ == 5000 } @list; my $n2 = true { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &true( 42, 4711 ); } ); } sub test_false { # The null set should return zero my $null_scalar = false {}; my @null_list = false {}; is( $null_scalar, 0, 'false(null) returns undef' ); is_deeply( \@null_list, [0], 'false(null) returns undef' ); # Normal cases my @list = ( 1 .. 10000 ); is( 10000, false { not defined } @list ); is( 0, false {defined} @list ); is( 1, false { $_ > 1 } @list ); leak_free_ok( false => sub { my $n = false { $_ == 5000 } @list; my $n2 = false { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &false( 42, 4711 ); } ); } sub test_firstidx { my @list = ( 1 .. 10000 ); is( 4999, ( firstidx { $_ >= 5000 } @list ), "firstidx" ); is( -1, ( firstidx { not defined } @list ), "invalid firstidx" ); is( 0, ( firstidx {defined} @list ), "real firstidx" ); is( -1, ( firstidx {} ), "empty firstidx" ); # Test the alias is( 4999, first_index { $_ >= 5000 } @list ); is( -1, first_index { not defined } @list ); is( 0, first_index {defined} @list ); is( -1, first_index {} ); leak_free_ok( firstidx => sub { my $i = firstidx { $_ >= 5000 } @list; my $i2 = firstidx { $_ >= 5000 } 1 .. 10000; } ); is_dying( sub { &firstidx( 42, 4711 ); } ); } sub test_lastidx { my @list = ( 1 .. 10000 ); is( 9999, lastidx { $_ >= 5000 } @list ); is( -1, lastidx { not defined } @list ); is( 9999, lastidx {defined} @list ); is( -1, lastidx {} ); # Test aliases is( 9999, last_index { $_ >= 5000 } @list ); is( -1, last_index { not defined } @list ); is( 9999, last_index {defined} @list ); is( -1, last_index {} ); leak_free_ok( lastidx => sub { my $i = lastidx { $_ >= 5000 } @list; my $i2 = lastidx { $_ >= 5000 } 1 .. 10000; } ); is_dying( sub { &lastidx( 42, 4711 ); } ); } sub test_onlyidx { my @list = ( 1 .. 300 ); is( 0, onlyidx { 1 == $_ } @list ); is( 149, onlyidx { 150 == $_ } @list ); is( 299, onlyidx { 300 == $_ } @list ); is( -1, onlyidx { 0 == $_ } @list ); is( -1, onlyidx { 1 <= $_ } @list ); is( -1, onlyidx { !( 127 & $_ ) } @list ); # Test aliases is( 0, only_index { 1 == $_ } @list ); is( 149, only_index { 150 == $_ } @list ); is( 299, only_index { 300 == $_ } @list ); is( -1, only_index { 0 == $_ } @list ); is( -1, only_index { 1 <= $_ } @list ); is( -1, only_index { !( 127 & $_ ) } @list ); leak_free_ok( onlyidx => sub { my $ok = onlyidx { 150 <= $_ } @list; my $ok2 = onlyidx { 150 <= $_ } 1 .. 300; } ); is_dying( sub { &onlyidx( 42, 4711 ); } ); } sub test_insert_after { my @list = qw{This is a list}; insert_after { $_ eq "a" } "longer" => @list; is( join( ' ', @list ), "This is a longer list" ); insert_after {0} "bla" => @list; is( join( ' ', @list ), "This is a longer list" ); insert_after { $_ eq "list" } "!" => @list; is( join( ' ', @list ), "This is a longer list !" ); @list = ( qw{This is}, undef, qw{list} ); insert_after { not defined($_) } "longer" => @list; $list[2] = "a"; is( join( ' ', @list ), "This is a longer list" ); leak_free_ok( insert_after => sub { @list = qw{This is a list}; insert_after { $_ eq 'a' } "longer" => @list; } ); is_dying( sub { &insert_after( 42, 4711, [qw(die bart die)] ); } ); is_dying( sub { &insert_after( 42, 4711, "13" ); } ); is_dying( sub { &insert_after( sub { }, 4711, "13" ); } ); } sub test_insert_after_string { my @list = qw{This is a list}; insert_after_string "a", "longer" => @list; is( join( ' ', @list ), "This is a longer list" ); @list = ( undef, qw{This is a list} ); insert_after_string "a", "longer", @list; shift @list; is( join( ' ', @list ), "This is a longer list" ); @list = ( "This\0", "is\0", "a\0", "list\0" ); insert_after_string "a\0", "longer\0", @list; is( join( ' ', @list ), "This\0 is\0 a\0 longer\0 list\0" ); leak_free_ok( insert_after_string => sub { @list = qw{This is a list}; insert_after_string "a", "longer", @list; } ); is_dying( sub { &insert_after_string( 42, 4711, "13" ); } ); } sub test_apply { # Test the null case my $null_scalar = apply {}; is( $null_scalar, undef, 'apply(null) returns undef' ); my @null_list = apply {}; is_deeply( \@null_list, [], 'apply(null) returns null list' ); # Normal cases my @list = ( 0 .. 9 ); my @list1 = apply { $_++ } @list; ok( is_deeply( \@list, [ 0 .. 9 ] ) ); ok( is_deeply( \@list1, [ 1 .. 10 ] ) ); @list = ( " foo ", " bar ", " ", "foobar" ); @list1 = apply {s/^\s+|\s+$//g} @list; ok( is_deeply( \@list, [ " foo ", " bar ", " ", "foobar" ] ) ); ok( is_deeply( \@list1, [ "foo", "bar", "", "foobar" ] ) ); my $item = apply {s/^\s+|\s+$//g} @list; is( $item, "foobar" ); # RT 38630 SCOPE: { # wrong results from apply() [XS] @list = ( 1 .. 4 ); @list1 = apply { grow_stack(); $_ = 5; } @list; ok( is_deeply( \@list, [ 1 .. 4 ] ) ); ok( is_deeply( \@list1, [ (5) x 4 ] ) ); } leak_free_ok( apply => sub { @list = ( 1 .. 4 ); @list1 = apply { grow_stack(); $_ = 5; } @list; } ); is_dying( sub { &apply( 42, 4711 ); } ); } sub test_indexes { my @x = indexes { $_ > 5 } ( 4 .. 9 ); ok( is_deeply( \@x, [ 2 .. 5 ] ) ); @x = indexes { $_ > 5 } ( 1 .. 4 ); is_deeply( \@x, [], 'Got the null list' ); my ( $lr, @s, @n, @o, @e ); leak_free_ok( indexes => sub { $lr = 1; @s = indexes { $_ > 5 } ( 4 .. 9 ); @n = indexes { $_ > 5 } ( 1 .. 5 ); @o = indexes { $_ & 1 } ( 10 .. 15 ); @e = indexes { !( $_ & 1 ) } ( 10 .. 15 ); } ); $lr and is_deeply( \@s, [ 2 .. 5 ], "indexes/leak: some" ); $lr and is_deeply( \@n, [], "indexes/leak: none" ); $lr and is_deeply( \@o, [ 1, 3, 5 ], "indexes/leak: odd" ); $lr and is_deeply( \@e, [ 0, 2, 4 ], "indexes/leak: even" ); leak_free_ok( indexes => sub { @s = indexes { grow_stack; $_ > 5 } ( 4 .. 9 ); @n = indexes { grow_stack; $_ > 5 } ( 1 .. 4 ); @o = indexes { grow_stack; $_ & 1 } ( 10 .. 15 ); @e = indexes { grow_stack; !( $_ & 1 ) } ( 10 .. 15 ); } ); $lr and is_deeply( \@s, [ 2 .. 5 ], "indexes/leak: some" ); $lr and is_deeply( \@n, [], "indexes/leak: none" ); $lr and is_deeply( \@o, [ 1, 3, 5 ], "indexes/leak: odd" ); $lr and is_deeply( \@e, [ 0, 2, 4 ], "indexes/leak: even" ); my $ref = \( indexes( sub {1}, 123 ) ); weaken($ref); is( $ref, undef, "weakened away" ); is_dying( sub { &indexes( 42, 4711 ); } ); } # In the following, the @dummy variable is needed to circumvent # a parser glitch in the 5.6.x series. sub test_before { my @x = before { $_ % 5 == 0 } 1 .. 9; ok( is_deeply( \@x, [ 1, 2, 3, 4 ] ) ); @x = before {/b/} my @dummy = qw{ bar baz }; is_deeply( \@x, [], 'Got the null list' ); @x = before {/f/} @dummy = qw{ bar baz foo }; ok( is_deeply( \@x, [qw{ bar baz }] ) ); leak_free_ok( before => sub { @x = before {/f/} @dummy = qw{ bar baz foo }; } ); is_dying( sub { &before( 42, 4711 ); } ); } # In the following, the @dummy variable is needed to circumvent # a parser glitch in the 5.6.x series. sub test_before_incl { my @x = before_incl { $_ % 5 == 0 } 1 .. 9; ok( is_deeply( \@x, [ 1, 2, 3, 4, 5 ] ) ); @x = before_incl {/foo/} my @dummy = qw{ bar baz }; ok( is_deeply( \@x, [qw{ bar baz }] ) ); @x = before_incl {/f/} @dummy = qw{ bar baz foo }; ok( is_deeply( \@x, [qw{ bar baz foo }] ) ); leak_free_ok( before_incl => sub { @x = before_incl {/z/} @dummy = qw{ bar baz foo }; } ); is_dying( sub { &before_incl( 42, 4711 ); } ); } # In the following, the @dummy variable is needed to circumvent # a parser glitch in the 5.6.x series. sub test_after { my @x = after { $_ % 5 == 0 } 1 .. 9; ok( is_deeply( \@x, [ 6, 7, 8, 9 ] ) ); @x = after {/foo/} my @dummy = qw{ bar baz }; is_deeply( \@x, [], 'Got the null list' ); @x = after {/b/} @dummy = qw{ bar baz foo }; ok( is_deeply( \@x, [qw{ baz foo }] ) ); leak_free_ok( after => sub { @x = after {/z/} @dummy = qw{ bar baz foo }; } ); is_dying( sub { &after( 42, 4711 ); } ); @x = ( 1, after {/foo/} qw(abc def) ); is_deeply( \@x, [1], "check XS implementation doesn't mess up stack" ); } # In the following, the @dummy variable is needed to circumvent # a parser glitch in the 5.6.x series. sub test_after_incl { my @x = after_incl { $_ % 5 == 0 } 1 .. 9; ok( is_deeply( \@x, [ 5, 6, 7, 8, 9 ] ) ); @x = after_incl {/foo/} my @dummy = qw{ bar baz }; is_deeply( \@x, [], 'Got the null list' ); @x = after_incl {/b/} @dummy = qw{ bar baz foo }; ok( is_deeply( \@x, [qw{ bar baz foo }] ) ); leak_free_ok( after_incl => sub { @x = after_incl {/z/} @dummy = qw{ bar baz foo }; } ); is_dying( sub { &after_incl( 42, 4711 ); } ); } sub test_firstval { my $x = firstval { $_ > 5 } 4 .. 9; is( $x, 6 ); $x = firstval { $_ > 5 } 1 .. 4; is( $x, undef ); is_undef( firstval { $_ > 5 } ); # Test aliases $x = first_value { $_ > 5 } 4 .. 9; is( $x, 6 ); $x = first_value { $_ > 5 } 1 .. 4; is( $x, undef ); leak_free_ok( firstval => sub { $x = firstval { $_ > 5 } 4 .. 9; } ); is_dying( sub { &firstval( 42, 4711 ); } ); } sub test_onlyval { my @list = ( 1 .. 300 ); is( 1, onlyval { 1 == $_ } @list ); is( 150, onlyval { 150 == $_ } @list ); is( 300, onlyval { 300 == $_ } @list ); is( undef, onlyval { 0 == $_ } @list ); is( undef, onlyval { 1 <= $_ } @list ); is( undef, onlyval { !( 127 & $_ ) } @list ); # Test aliases is( 1, only_value { 1 == $_ } @list ); is( 150, only_value { 150 == $_ } @list ); is( 300, only_value { 300 == $_ } @list ); is( undef, only_value { 0 == $_ } @list ); is( undef, only_value { 1 <= $_ } @list ); is( undef, only_value { !( 127 & $_ ) } @list ); leak_free_ok( onlyval => sub { my $ok = onlyval { 150 <= $_ } @list; my $ok2 = onlyval { 150 <= $_ } 1 .. 300; } ); is_dying( sub { &onlyval( 42, 4711 ); } ); } sub test_lastval { my $x = lastval { $_ > 5 } 4 .. 9; is( $x, 9 ); $x = lastval { $_ > 5 } 1 .. 4; is( $x, undef ); is_undef( lastval { $_ > 5 } ); # Test aliases $x = last_value { $_ > 5 } 4 .. 9; is( $x, 9 ); $x = last_value { $_ > 5 } 1 .. 4; is( $x, undef ); leak_free_ok( lastval => sub { $x = lastval { $_ > 5 } 4 .. 9; } ); is_dying( sub { &lastval( 42, 4711 ); } ); } sub test_firstres { my $x = firstres { 2 * ( $_ > 5 ) } 4 .. 9; is( $x, 2 ); $x = firstres { $_ > 5 } 1 .. 4; is( $x, undef ); # Test aliases $x = first_result { $_ > 5 } 4 .. 9; is( $x, 1 ); $x = first_result { $_ > 5 } 1 .. 4; is( $x, undef ); leak_free_ok( firstres => sub { $x = firstres { $_ > 5 } 4 .. 9; } ); is_dying( sub { &firstres( 42, 4711 ); } ); } sub test_lastres { my $x = lastres { 2 * ( $_ > 5 ) } 4 .. 9; is( $x, 2 ); $x = lastres { $_ > 5 } 1 .. 4; is( $x, undef ); # Test aliases $x = last_result { $_ > 5 } 4 .. 9; is( $x, 1 ); $x = last_result { $_ > 5 } 1 .. 4; is( $x, undef ); leak_free_ok( lastres => sub { $x = lastres { $_ > 5 } 4 .. 9; } ); is_dying( sub { &lastres( 42, 4711 ); } ); } sub test_onlyres { my @list = ( 1 .. 300 ); is( "Hallelujah", onlyres { 150 == $_ and "Hallelujah" } @list ); is( 1, onlyres { 300 == $_ } @list ); is( undef, onlyres { 0 == $_ } @list ); is( undef, onlyres { 1 <= $_ } @list ); is( undef, onlyres { !( 127 & $_ ) } @list ); # Test aliases is( 1, only_result { 150 == $_ } @list ); is( "Hallelujah", only_result { 300 == $_ and "Hallelujah" } @list ); is( undef, only_result { 0 == $_ } @list ); is( undef, only_result { 1 <= $_ } @list ); is( undef, only_result { !( 127 & $_ ) } @list ); leak_free_ok( onlyres => sub { my $ok = onlyres { 150 <= $_ } @list; my $ok2 = onlyres { 150 <= $_ } 1 .. 300; } ); is_dying( sub { &onlyres( 42, 4711 ); } ); } sub test_each_array { SCOPE: { my @a = ( 7, 3, 'a', undef, 'r' ); my @b = qw{ a 2 -1 x }; my $it = each_array @a, @b; my ( @r, @idx ); while ( my ( $a, $b ) = $it->() ) { push @r, $a, $b; push @idx, $it->('index'); } # Do I segfault? I shouldn't. $it->(); ok( is_deeply( \@r, [ 7, 'a', 3, 2, 'a', -1, undef, 'x', 'r', undef ] ) ); ok( is_deeply( \@idx, [ 0 .. 4 ] ) ); # Testing two iterators on the same arrays in parallel @a = ( 1, 3, 5 ); @b = ( 2, 4, 6 ); my $i1 = each_array @a, @b; my $i2 = each_array @a, @b; @r = (); while ( my ( $a, $b ) = $i1->() and my ( $c, $d ) = $i2->() ) { push @r, $a, $b, $c, $d; } ok( is_deeply( \@r, [ 1, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6 ] ) ); # Input arrays must not be modified ok( is_deeply( \@a, [ 1, 3, 5 ] ) ); ok( is_deeply( \@b, [ 2, 4, 6 ] ) ); # This used to give "semi-panic: attempt to dup freed string" # See: my $ea = each_arrayref( [ 1 .. 26 ], [ 'A' .. 'Z' ] ); ( @a, @b ) = (); while ( my ( $a, $b ) = $ea->() ) { push @a, $a; push @b, $b; } ok( is_deeply( \@a, [ 1 .. 26 ] ) ); ok( is_deeply( \@b, [ 'A' .. 'Z' ] ) ); # And this even used to dump core my @nums = 1 .. 26; $ea = each_arrayref( \@nums, [ 'A' .. 'Z' ] ); ( @a, @b ) = (); while ( my ( $a, $b ) = $ea->() ) { push @a, $a; push @b, $b; } ok( is_deeply( \@a, [ 1 .. 26 ] ) ); ok( is_deeply( \@a, \@nums ) ); ok( is_deeply( \@b, [ 'A' .. 'Z' ] ) ); } SCOPE: { my @a = ( 7, 3, 'a', undef, 'r' ); my @b = qw/a 2 -1 x/; my $it = each_arrayref \@a, \@b; my ( @r, @idx ); while ( my ( $a, $b ) = $it->() ) { push @r, $a, $b; push @idx, $it->('index'); } # Do I segfault? I shouldn't. $it->(); ok( is_deeply( \@r, [ 7, 'a', 3, 2, 'a', -1, undef, 'x', 'r', undef ] ) ); ok( is_deeply( \@idx, [ 0 .. 4 ] ) ); # Testing two iterators on the same arrays in parallel @a = ( 1, 3, 5 ); @b = ( 2, 4, 6 ); my $i1 = each_array @a, @b; my $i2 = each_array @a, @b; @r = (); while ( my ( $a, $b ) = $i1->() and my ( $c, $d ) = $i2->() ) { push @r, $a, $b, $c, $d; } ok( is_deeply( \@r, [ 1, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6 ] ) ); # Input arrays must not be modified ok( is_deeply( \@a, [ 1, 3, 5 ] ) ); ok( is_deeply( \@b, [ 2, 4, 6 ] ) ); } # Note that the leak_free_ok tests for each_array and each_arrayref # should not be run until either of them has been called at least once # in the current perl. That's because calling them the first time # causes the runtime to allocate some memory used for the OO structures # that their implementation uses internally. leak_free_ok( each_array => sub { my @a = (1); my $it = each_array @a; while ( my ($a) = $it->() ) { } } ); leak_free_ok( each_arrayref => sub { my @a = (1); my $it = each_arrayref \@a; while ( my ($a) = $it->() ) { } } ); is_dying( sub { &each_array( 42, 4711 ); } ); is_dying( sub { &each_arrayref( 42, 4711 ); } ); } sub test_pairwise { my @a = ( 1, 2, 3, 4, 5 ); my @b = ( 2, 4, 6, 8, 10 ); my @c = pairwise { $a + $b } @a, @b; is_deeply( \@c, [ 3, 6, 9, 12, 15 ], "pw1" ); @c = pairwise { $a * $b } @a, @b; # returns (2, 8, 18) is_deeply( \@c, [ 2, 8, 18, 32, 50 ], "pw2" ); # Did we modify the input arrays? is_deeply( \@a, [ 1, 2, 3, 4, 5 ], "pw3" ); is_deeply( \@b, [ 2, 4, 6, 8, 10 ], "pw4" ); # $a and $b should be aliases: test @b = @a = ( 1, 2, 3 ); @c = pairwise { $a++; $b *= 2 } @a, @b; is_deeply( \@a, [ 2, 3, 4 ], "pw5" ); is_deeply( \@b, [ 2, 4, 6 ], "pw6" ); is_deeply( \@c, [ 2, 4, 6 ], "pw7" ); # sub returns more than two items @a = ( 1, 1, 2, 3, 5 ); @b = ( 2, 3, 5, 7, 11 ); @c = pairwise { ($a) x $b } @a, @b; is_deeply( \@c, [ (1) x 2, (1) x 3, (2) x 5, (3) x 7, (5) x 11 ], "pw8" ); ( @a, @b ) = (); push @a, int rand(1000) for 0 .. rand(1000); push @b, int rand(1000) for 0 .. rand(1000); SCOPE: { local $SIG{__WARN__} = sub { }; # XXX my @res1 = pairwise { $a + $b } @a, @b; # Test this one more thoroughly: the XS code looks flakey # correctness of pairwise_perl proved by human auditing. :-) my $limit = $#a > $#b ? $#a : $#b; my @res2 = map { $a[$_] + $b[$_] } 0 .. $limit; is_deeply( \@res1, \@res2 ); } @a = qw/a b c/; @b = qw/1 2 3/; @c = pairwise { ( $a, $b ) } @a, @b; is_deeply( \@c, [qw/a 1 b 2 c 3/], "pw map" ); SKIP: { $ENV{PERL5OPT} and skip 'A defined PERL5OPT may inject extra deps crashing this test', 1; # Test that a die inside the code-reference will not be trapped eval { pairwise { die "I died\n" } @a, @b; }; is( $@, "I died\n" ); } leak_free_ok( pairwise => sub { @a = (1); @b = (2); @c = pairwise { $a + $b } @a, @b; } ); @a = qw/a b c/; @b = qw/1 2 3/; SKIP: { List::SomeUtils::_XScompiled or skip "PurePerl will warn here ...", 1; my ( $a, $b, @t ); eval { my @l1 = ( 1 .. 10 ); @t = pairwise { $a + $b } @l1, @l1; }; my $err = $@; like( $err, qr/Can't use lexical \$a or \$b in pairwise code block/, "pairwise die's on broken caller" ); } SKIP: { List::SomeUtils::_XScompiled and skip "XS will die on purpose here ...", 1; my @warns = (); local $SIG{__WARN__} = sub { push @warns, @_ }; my ( $a, $b, @t ); my @l1 = ( 1 .. 10 ); @t = pairwise { $a + $b } @l1, @l1; like( join( "", @warns[ 0, 1 ] ), qr/Use of uninitialized value.*? in addition/, "warning on broken caller" ); } is_dying( sub { &pairwise( 42, \@a, \@b ); } ); SKIP: { List::SomeUtils::_XScompiled or skip "PurePerl will not core here ...", 2; is_dying( sub { @c = &pairwise( sub { }, 1, \@b ); } ); is_dying( sub { @c = &pairwise( sub { }, \@a, 2 ); } ); } } sub test_natatime { my @x = ( 'a' .. 'g' ); my $it = natatime 3, @x; my @r; local $" = " "; while ( my @vals = $it->() ) { push @r, "@vals"; } is( is_deeply( \@r, [ 'a b c', 'd e f', 'g' ] ), 1, "natatime1" ); my @a = ( 1 .. 1000 ); $it = natatime 1, @a; @r = (); while ( my @vals = &$it ) { push @r, @vals; } is( is_deeply( \@r, \@a ), 1, "natatime2" ); leak_free_ok( natatime => sub { my @y = 1; my $it = natatime 2, @y; while ( my @vals = $it->() ) { # do nothing } } ); } sub test_zip { SCOPE: { my @x = qw/a b c d/; my @y = qw/1 2 3 4/; my @z = zip @x, @y; ok( is_deeply( \@z, [ 'a', 1, 'b', 2, 'c', 3, 'd', 4 ] ) ); } SCOPE: { my @a = ('x'); my @b = ( '1', '2' ); my @c = qw/zip zap zot/; my @z = zip @a, @b, @c; ok( is_deeply( \@z, [ 'x', 1, 'zip', undef, 2, 'zap', undef, undef, 'zot' ] ) ); } SCOPE: { # Make array with holes my @a = ( 1 .. 10 ); my @d; $#d = 9; my @z = zip @a, @d; ok( is_deeply( \@z, [ 1, undef, 2, undef, 3, undef, 4, undef, 5, undef, 6, undef, 7, undef, 8, undef, 9, undef, 10, undef, ] ) ); } leak_free_ok( zip => sub { my @x = qw/a b c d/; my @y = qw/1 2 3 4/; my @z = zip @x, @y; } ); is_dying( sub { &zip( 1, 2 ); } ); } sub test_mesh { SCOPE: { my @x = qw/a b c d/; my @y = qw/1 2 3 4/; my @z = mesh @x, @y; ok( is_deeply( \@z, [ 'a', 1, 'b', 2, 'c', 3, 'd', 4 ] ) ); } SCOPE: { my @a = ('x'); my @b = ( '1', '2' ); my @c = qw/zip zap zot/; my @z = mesh @a, @b, @c; ok( is_deeply( \@z, [ 'x', 1, 'zip', undef, 2, 'zap', undef, undef, 'zot' ] ) ); } # Make array with holes SCOPE: { my @a = ( 1 .. 10 ); my @d; $#d = 9; my @z = mesh @a, @d; ok( is_deeply( \@z, [ 1, undef, 2, undef, 3, undef, 4, undef, 5, undef, 6, undef, 7, undef, 8, undef, 9, undef, 10, undef, ] ) ); } leak_free_ok( mesh => sub { my @x = qw/a b c d/; my @y = qw/1 2 3 4/; my @z = mesh @x, @y; } ); is_dying( sub { &mesh( 1, 2 ); } ); } sub test_uniq { SCOPE: { my @a = map { ( 1 .. 10 ) } 0 .. 1; my @u = uniq @a; is_deeply( \@u, [ 1 .. 10 ] ); my $u = uniq @a; is( 10, $u ); } # Test aliases SCOPE: { my @a = map { ( 1 .. 10 ) } 0 .. 1; my @u = distinct @a; is_deeply( \@u, [ 1 .. 10 ] ); my $u = distinct @a; is( 10, $u ); } # Test strings SCOPE: { my @a = map { ( "a" .. "z" ) } 0 .. 1; my @u = uniq @a; is_deeply( \@u, [ "a" .. "z" ] ); my $u = uniq @a; is( 26, $u ); } # Test mixing strings and numbers SCOPE: { my @a = ( ( map { ( 1 .. 10 ) } 0 .. 1 ), ( map { ( "a" .. "z" ) } 0 .. 1 ) ); my $fa = freeze( \@a ); my @u = uniq map {$_} @a; my $fu = freeze( \@u ); is_deeply( \@u, [ 1 .. 10, "a" .. "z" ] ); is( $fa, freeze( \@a ) ); is( $fu, freeze( [ 1 .. 10, "a" .. "z" ] ) ); my $u = uniq @a; is( 10 + 26, $u ); } SCOPE: { my @a; tie @a, "Tie::StdArray"; @a = ( ( map { ( 1 .. 10 ) } 0 .. 1 ), ( map { ( "a" .. "z" ) } 0 .. 1 ) ); my @u = uniq @a; is_deeply( \@u, [ 1 .. 10, "a" .. "z" ] ); @a = ( ( map { ( 1 .. 10 ) } 0 .. 1 ), ( map { ( "a" .. "z" ) } 0 .. 1 ) ); my $u = uniq @a; is( 10 + 26, $u ); } SCOPE: { my @foo = ( 'a', 'b', '', undef, 'b', 'c', '' ); my @ufoo = ( 'a', 'b', '', undef, 'c' ); is_deeply( [ uniq @foo ], \@ufoo, 'undef is supported correctly' ); } leak_free_ok( uniq => sub { my @a = map { ( 1 .. 1000 ) } 0 .. 1; my @u = uniq @a; uniq @a[ 1 .. 100 ]; } ); # This test (and the associated fix) are from Kevin Ryde; see RT#49796 leak_free_ok( 'uniq with exception in overloading stringify', sub { eval { my $obj = DieOnStringify->new; my @u = uniq $obj, $obj; }; eval { my $obj = DieOnStringify->new; my $u = uniq $obj, $obj; }; } ); } sub test_singleton { SCOPE: { my @s = ( 1001 .. 1200 ); my @d = map { ( 1 .. 1000 ) } 0 .. 1; my @a = ( @d, @s ); my @u = singleton @a; is_deeply( \@u, [@s] ); my $u = singleton @a; is( 200, $u ); } # Test strings SCOPE: { my @s = ( "AA" .. "ZZ" ); my @d = map { ( "aa" .. "zz" ) } 0 .. 1; my @a = ( @d, @s ); my @u = singleton @a; is_deeply( \@u, [@s] ); my $u = singleton @a; is( scalar @s, $u ); } # Test mixing strings and numbers SCOPE: { my @s = ( 1001 .. 1200, "AA" .. "ZZ" ); my $fs = freeze( \@s ); my @d = map { ( 1 .. 1000, "aa" .. "zz" ) } 0 .. 1; my @a = ( @d, @s ); my $fa = freeze( \@a ); my @u = singleton map {$_} @a; my $fu = freeze( \@u ); is_deeply( \@u, [@s] ); is( $fs, freeze( \@s ) ); is( $fa, freeze( \@a ) ); is( $fu, $fs ); my $u = singleton @a; is( scalar @s, $u ); } SCOPE: { my @a; tie @a, "Tie::StdArray"; my @s = ( 1001 .. 1200, "AA" .. "ZZ" ); my @d = map { ( 1 .. 1000, "aa" .. "zz" ) } 0 .. 1; @a = ( @d, @s ); my @u = singleton map {$_} @a; is_deeply( \@u, [@s] ); @a = ( @d, @s ); my $u = singleton @a; is( scalar @s, $u ); } SCOPE: { my @foo = ( 'a', 'b', '', undef, 'b', 'c', '' ); my @sfoo = ( 'a', undef, 'c' ); is_deeply( [ singleton @foo ], \@sfoo, 'one undef is supported correctly by singleton' ); @foo = ( 'a', 'b', '', undef, 'b', 'c', undef ); @sfoo = ( 'a', '', 'c' ); is_deeply( [ singleton @foo ], \@sfoo, 'twice undef is supported correctly by singleton' ); is( ( scalar singleton @foo ), scalar @sfoo, 'scalar twice undef is supported correctly by singleton' ); } leak_free_ok( uniq => sub { my @s = ( 1001 .. 1200, "AA" .. "ZZ" ); my @d = map { ( 1 .. 1000, "aa" .. "zz" ) } 0 .. 1; my @a = ( @d, @s ); my @u = singleton @a; scalar singleton @a; } ); # This test (and the associated fix) are from Kevin Ryde; see RT#49796 leak_free_ok( 'singleton with exception in overloading stringify', sub { eval { my $obj = DieOnStringify->new; my @u = singleton $obj, $obj; }; eval { my $obj = DieOnStringify->new; my $u = singleton $obj, $obj; }; } ); } sub test_part { my @list = 1 .. 12; my $i = 0; my @part = part { $i++ % 3 } @list; ok( is_deeply( $part[0], [ 1, 4, 7, 10 ] ) ); ok( is_deeply( $part[1], [ 2, 5, 8, 11 ] ) ); ok( is_deeply( $part[2], [ 3, 6, 9, 12 ] ) ); $list[2] = 0; is( $part[2][0], 3, 'Values are not aliases' ); @list = 1 .. 12; @part = part {3} @list; is( $part[0], undef ); is( $part[1], undef ); is( $part[2], undef ); ok( is_deeply( $part[3], [ 1 .. 12 ] ) ); eval { @part = part {-1} @list; }; like( $@, qr/^Modification of non-creatable array value attempted, subscript -1/ ); $i = 0; @part = part { $i++ == 0 ? 0 : -1 } @list; is_deeply( $part[0], [ 1 .. 12 ], "part with negative indices" ); SKIP: { List::SomeUtils::_XScompiled and skip "Only PurePerl will warn here ...", 1; my @warns = (); local $SIG{__WARN__} = sub { push @warns, [@_] }; @part = part {undef} @list; is_deeply( $part[0], [ 1 .. 12 ], "part with undef" ); like( join( "\n", @{ $warns[0] } ), qr/Use of uninitialized value in array element.*line\s+\d+\.$/, "warning of undef" ); is_deeply( \@warns, [ ( $warns[0] ) x 12 ], "amount of similar undef warnings" ); } @part = part {10000} @list; ok( is_deeply( $part[10000], [@list] ) ); is( $part[0], undef ); is( $part[ @part / 2 ], undef ); is( $part[9999], undef ); # Changing the list in place used to destroy # its elements due to a wrong refcnt @list = 1 .. 10; @list = part {$_} @list; foreach ( 1 .. 10 ) { ok( is_deeply( $list[$_], [$_] ) ); } leak_free_ok( part => sub { my @list = 1 .. 12; my $i = 0; my @part = part { $i++ % 3 } @list; } ); leak_free_ok( 'part with stack-growing' => sub { # This test is from Kevin Ryde; see RT#38699 my @part = part { grow_stack(); 1024 } 'one', 'two'; } ); } sub test_minmax { my @list = reverse 0 .. 10000; my ( $min, $max ) = minmax @list; is( $min, 0 ); is( $max, 10000 ); # Even number of elements push @list, 10001; ( $min, $max ) = minmax @list; is( $min, 0 ); is( $max, 10001 ); $list[0] = 17; # Some floats @list = ( 0, -1.1, 3.14, 1 / 7, 10000, -10 / 3 ); ( $min, $max ) = minmax @list; # Floating-point comparison cunningly avoided is( sprintf( "%.2f", $min ), "-3.33" ); is( $max, 10000 ); # Test with a single negative list value my $input = -1; ( $min, $max ) = minmax $input; is( $min, -1 ); is( $max, -1 ); # COW causes missing max when optimization for 1 argument is applied @list = grep { defined $_ } map { my ( $min, $max ) = minmax( sprintf( "%.3g", rand ) ); ( $min, $max ) } ( 0 .. 19 ); is( scalar @list, 40, "minmax swallows max on COW" ); # Confirm output are independant copies of input $input = 1; is( $min, -1 ); is( $max, -1 ); $min = 2; is( $max, -1 ); # prove overrun my $uvmax = ~0; my $ivmax = $uvmax >> 1; my $ivmin = ( 0 - $ivmax ) - 1; my @low_ints = map { $ivmin + $_ } ( 0 .. 10 ); ( $min, $max ) = minmax @low_ints; is( $min, $ivmin, "minmax finds ivmin" ); is( $max, $ivmin + 10, "minmax finds ivmin + 10" ); my @high_ints = map { $ivmax - $_ } ( 0 .. 10 ); ( $min, $max ) = minmax @high_ints; is( $min, $ivmax - 10, "minmax finds ivmax-10" ); is( $max, $ivmax, "minmax finds ivmax" ); my @mixed_ints = map { ( $ivmin + $_, $ivmax - $_ ) } ( 0 .. 10 ); ( $min, $max ) = minmax @mixed_ints; is( $min, $ivmin, "minmax finds ivmin" ); is( $max, $ivmax, "minmax finds ivmax" ); my @high_uints = map { $uvmax - $_ } ( 0 .. 10 ); ( $min, $max ) = minmax @high_uints; is( $min, $uvmax - 10, "minmax finds uvmax-10" ); is( $max, $uvmax, "minmax finds uvmax" ); my @mixed_nums = map { ( $ivmin + $_, $uvmax - $_ ) } ( 0 .. 10 ); ( $min, $max ) = minmax @mixed_nums; is( $min, $ivmin, "minmax finds ivmin" ); is( $max, $uvmax, "minmax finds uvmax" ); leak_free_ok( minmax => sub { @list = ( 0, -1.1, 3.14, 1 / 7, 10000, -10 / 3 ); ( $min, $max ) = minmax @list; } ); } sub test_bsearch { my @list = my @in = 1 .. 1000; for my $elem (@in) { ok( scalar bsearch { $_ - $elem } @list ); } for my $elem (@in) { my ($e) = bsearch { $_ - $elem } @list; ok( $e == $elem ); } my @out = ( -10 .. 0, 1001 .. 1011 ); for my $elem (@out) { my $r = bsearch { $_ - $elem } @list; ok( !defined $r ); } leak_free_ok( bsearch => sub { my $elem = int( rand(1000) ) + 1; scalar bsearch { $_ - $elem } @list; } ); leak_free_ok( 'bsearch with stack-growing' => sub { my $elem = int( rand(1000) ); scalar bsearch { grow_stack(); $_ - $elem } @list; } ); leak_free_ok( 'bsearch with stack-growing and exception' => sub { my $elem = int( rand(1000) ); eval { scalar bsearch { grow_stack(); $_ - $elem or die "Goal!"; $_ - $elem } @list; }; } ); is_dying( sub { &bsearch( 42, ( 1 .. 100 ) ); } ); } sub test_bsearchidx { my @list = my @in = 1 .. 1000; for my $i ( 0 .. $#in ) { is( $i, bsearchidx { $_ - $in[$i] } @list ); } my @out = ( -10 .. 0, 1001 .. 1011 ); for my $elem (@out) { my $r = bsearchidx { $_ - $elem } @list; is( -1, $r ); } leak_free_ok( bsearch => sub { my $elem = int( rand(1000) ) + 1; bsearchidx { $_ - $elem } @list; } ); leak_free_ok( 'bsearch with stack-growing' => sub { my $elem = int( rand(1000) ); bsearchidx { grow_stack(); $_ - $elem } @list; } ); leak_free_ok( 'bsearch with stack-growing and exception' => sub { my $elem = int( rand(1000) ); eval { bsearchidx { grow_stack(); $_ - $elem or die "Goal!"; $_ - $elem } @list; }; } ); is_dying( sub { &bsearchidx( 42, ( 1 .. 100 ) ); } ); } sub test_any { # Normal cases my @list = ( 1 .. 10000 ); is_true( any { $_ == 5000 } @list ); is_true( any { $_ == 5000 } 1 .. 10000 ); is_true( any {defined} @list ); is_false( any { not defined } @list ); is_true( any { not defined } undef ); is_false( any {} ); leak_free_ok( any => sub { my $ok = any { $_ == 5000 } @list; my $ok2 = any { $_ == 5000 } 1 .. 10000; } ); leak_free_ok( 'any with a coderef that dies' => sub { # This test is from Kevin Ryde; see RT#48669 eval { my $ok = any {die} 1; }; } ); is_dying( sub { &any( 42, 4711 ); } ); } sub test_all { # Normal cases my @list = ( 1 .. 10000 ); is_true( all {defined} @list ); is_true( all { $_ > 0 } @list ); is_false( all { $_ < 5000 } @list ); is_true( all {} ); leak_free_ok( all => sub { my $ok = all { $_ == 5000 } @list; my $ok2 = all { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &all( 42, 4711 ); } ); } sub test_none { # Normal cases my @list = ( 1 .. 10000 ); is_true( none { not defined } @list ); is_true( none { $_ > 10000 } @list ); is_false( none {defined} @list ); is_true( none {} ); leak_free_ok( none => sub { my $ok = none { $_ == 5000 } @list; my $ok2 = none { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { &none( 42, 4711 ); } ); } sub test_notall { # Normal cases my @list = ( 1 .. 10000 ); is_true( notall { !defined } @list ); is_true( notall { $_ < 10000 } @list ); is_false( notall { $_ <= 10000 } @list ); is_false( notall {} ); leak_free_ok( notall => sub { my $ok = notall { $_ == 5000 } @list; my $ok2 = notall { $_ == 5000 } 1 .. 10000; } ); is_dying( sub { ¬all( 42, 4711 ); } ); } sub test_one { # Normal cases my @list = ( 1 .. 300 ); is_true( one { 1 == $_ } @list ); is_true( one { 150 == $_ } @list ); is_true( one { 300 == $_ } @list ); is_false( one { 0 == $_ } @list ); is_false( one { 1 <= $_ } @list ); is_false( one { !( 127 & $_ ) } @list ); leak_free_ok( one => sub { my $ok = one { 150 <= $_ } @list; my $ok2 = one { 150 <= $_ } 1 .. 300; } ); is_dying( sub { &one( 42, 4711 ); } ); } sub test_sort_by { my @list = map { [$_] } 1 .. 100; is_deeply( [ sort_by { $_->[0] } @list ], [ map { [$_] } sort { $a cmp $b } 1 .. 100 ] ); } sub test_nsort_by { my @list = map { [$_] } 1 .. 100; is_deeply( [ nsort_by { $_->[0] } @list ], [ map { [$_] } sort { $a <=> $b } 1 .. 100 ] ); } sub test_mode { my @list = ( 1 .. 5 ); is_deeply( [ sort { $a <=> $b } mode(@list) ], [ sort @list ], 'mode of list without repeats is the list itself' ); is( scalar mode(@list), 5, 'mode returns modality in scalar context' ); @list = ( 1, 1 .. 5 ); is_deeply( [ mode(@list) ], [1], 'mode of list with one repeat is the repeated item' ); is( scalar mode(@list), 1, 'mode returns modality in scalar context' ); @list = ( 1, 1 .. 5, 5 ); is_deeply( [ sort { $a <=> $b } mode(@list) ], [ 1, 5 ], 'mode of bimodal list' ); is( scalar mode(@list), 2, 'mode returns modality in scalar context' ); @list = ( 1, 1 .. 5, 5, 9, 9 ); is_deeply( [ sort { $a <=> $b } mode(@list) ], [ 1, 5, 9 ], 'mode of trimodal list' ); @list = ( 1, 1, 1, 1 .. 5, 5, 9, 9 ); is_deeply( [ mode(@list) ], [1], 'mode of list with multiple repeats is the most repeated item' ); @list = (); is_deeply( [ mode() ], [], 'mode of empty list is an empty list' ); is( scalar mode(@list), 0, 'mode returns modality in scalar context' ); @list = qw( a a b c d ); is_deeply( [ mode(@list) ], ['a'], 'mode of list of strings' ); my $foo1 = Overloaded->new('foo'); my $foo2 = Overloaded->new('foo'); my $bar = Overloaded->new('bar'); @list = ( $foo1, $foo2, $bar ); is_deeply( [ sort( mode(@list) ) ], ['foo'], 'objects passed to mode are stringified' ); leak_free_ok( mode => sub { my @mode = mode(qw( a b c a b a b )); my $modality = mode(qw( a b c a b a b )); @mode = mode(); $modality = mode(); } ); } { package Overloaded; use overload q{""} => sub { $_[0]->{string} }; sub new { my $class = shift; return bless { string => shift }, $class; } } 1; List-SomeUtils-0.56/t/lib/LSU/Test/Import.pm0000644000175000017500000000121713134705504020347 0ustar autarchautarchpackage LSU::Test::Import; use strict; BEGIN { $| = 1; } use Test::More; sub run_tests { use_ok( "List::SomeUtils", qw(any all none notall any_u all_u none_u notall_u true false firstidx lastidx insert_after insert_after_string apply indexes after after_incl before before_incl firstval lastval each_array each_arrayref pairwise natatime mesh uniq minmax part bsearch sort_by nsort_by first_index last_index first_value last_value zip distinct) ); done_testing(); } 1; List-SomeUtils-0.56/t/lib/LSU/Test/ab.pm0000644000175000017500000000052113134705504017454 0ustar autarchautarchpackage LSU::Test::ab; use strict; BEGIN { $| = 1; } use Test::More; use List::SomeUtils 'pairwise'; sub run_tests { test_ab(); done_testing(); } sub test_ab { my @A = ( 1, 2, 3, 4, 5 ); my @B = ( 2, 4, 6, 8, 10 ); my @C = pairwise { $a + $b } @A, @B; is_deeply( \@C, [ 3, 6, 9, 12, 15 ], "pw1" ); } 1; List-SomeUtils-0.56/t/lib/Test/0000775000175000017500000000000013134705504016075 5ustar autarchautarchList-SomeUtils-0.56/t/lib/Test/LSU.pm0000644000175000017500000000333613134705504017101 0ustar autarchautarchpackage Test::LSU; use strict; require Exporter; use Test::More import => ['!pass']; use Carp qw/croak/; use base qw(Test::Builder::Module Exporter); our @EXPORT = qw(is_true is_false is_defined is_undef is_dying grow_stack leak_free_ok); our @EXPORT_OK = qw(is_true is_false is_defined is_undef is_dying grow_stack leak_free_ok); my $CLASS = __PACKAGE__; ###################################################################### # Support Functions sub is_true { @_ == 1 or croak "Expected 1 param"; my $tb = $CLASS->builder(); $tb->ok( $_[0], "is_true ()" ); } sub is_false { @_ == 1 or croak "Expected 1 param"; my $tb = $CLASS->builder(); $tb->ok( !$_[0], "is_false()" ); } sub is_defined { @_ < 1 or croak "Expected 0..1 param"; my $tb = $CLASS->builder(); $tb->ok( defined( $_[0] ), "is_defined ()" ); } sub is_undef { @_ <= 1 or croak "Expected 0..1 param"; my $tb = $CLASS->builder(); $tb->ok( !defined( $_[0] ), "is_undef()" ); } sub is_dying { @_ == 1 or croak "Expected 1 param"; my $tb = $CLASS->builder(); eval { $_[0]->(); }; $tb->ok( $@, "is_dying()" ); } my @bigary = (1) x 500; sub func { } sub grow_stack { func(@bigary); } my $have_test_leak_trace = eval { require Test::LeakTrace; 1 }; sub leak_free_ok { my $name = shift; my $code = shift; SKIP: { skip 'Test::LeakTrace not installed', 1 unless $have_test_leak_trace; local $Test::Builder::Level = $Test::Builder::Level + 1; &Test::LeakTrace::no_leaks_ok( $code, "No memory leaks in $name" ); } } { package DieOnStringify; use overload '""' => \&stringify; sub new { bless {}, shift } sub stringify { die 'DieOnStringify exception' } } 1; List-SomeUtils-0.56/t/Functions.t0000644000175000017500000000023713134705504016545 0ustar autarchautarchuse strict; use warnings; use lib 't/lib'; BEGIN { $ENV{LIST_SOMEUTILS_IMPLEMENTATION} = 'PP' } use LSU::Test::Functions; LSU::Test::Functions->run_tests; List-SomeUtils-0.56/inc/0000775000175000017500000000000013134705504014716 5ustar autarchautarchList-SomeUtils-0.56/inc/ExtUtils/0000775000175000017500000000000013134705504016477 5ustar autarchautarchList-SomeUtils-0.56/inc/ExtUtils/HasCompiler.pm0000644000175000017500000002203113134705504021237 0ustar autarchautarchpackage ExtUtils::HasCompiler; $ExtUtils::HasCompiler::VERSION = '0.021'; use strict; use warnings; use base 'Exporter'; our @EXPORT_OK = qw/can_compile_loadable_object can_compile_static_library can_compile_extension/; our %EXPORT_TAGS = (all => \@EXPORT_OK); use Config; use Carp 'carp'; use File::Basename 'basename'; use File::Spec::Functions qw/catfile catdir rel2abs/; use File::Temp qw/tempdir tempfile/; my $tempdir = tempdir('HASCOMPILERXXXX', CLEANUP => 1, DIR => '.'); my $loadable_object_format = <<'END'; #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef PERL_UNUSED_VAR #define PERL_UNUSED_VAR(var) #endif XS(exported) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XSRETURN_IV(42); } #ifndef XS_EXTERNAL #define XS_EXTERNAL(foo) XS(foo) #endif /* we don't want to mess with .def files on mingw */ #if defined(WIN32) && defined(__GNUC__) # define EXPORT __declspec(dllexport) #else # define EXPORT #endif EXPORT XS_EXTERNAL(boot_%s) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ newXS("%s::exported", exported, __FILE__); } END my $counter = 1; my %prelinking = map { $_ => 1 } qw/MSWin32 VMS aix/; sub can_compile_loadable_object { my %args = @_; my $output = $args{output} || \*STDOUT; my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; return if not $config->get('usedl'); my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); my $basename = basename($source_name, '.c'); my $abs_basename = catfile($tempdir, $basename); my ($cc, $ccflags, $optimize, $cccdlflags, $ld, $ldflags, $lddlflags, $libperl, $perllibs, $archlibexp, $_o, $dlext) = map { $config->get($_) } qw/cc ccflags optimize cccdlflags ld ldflags lddlflags libperl perllibs archlibexp _o dlext/; my $incdir = catdir($archlibexp, 'CORE'); my $object_file = $abs_basename.$_o; my $loadable_object = "$abs_basename.$dlext"; my @commands; if ($^O eq 'MSWin32' && $cc =~ /^cl/) { push @commands, qq{$cc $ccflags $cccdlflags $optimize /I "$incdir" /c $source_name /Fo$object_file}; push @commands, qq{$ld $object_file $lddlflags $libperl $perllibs /out:$loadable_object /def:$abs_basename.def /pdb:$abs_basename.pdb}; } elsif ($^O eq 'VMS') { # Mksymlists is only the beginning of the story. open my $opt_fh, '>>', "$abs_basename.opt" or do { carp "Couldn't append to '$abs_basename.opt'"; return }; print $opt_fh "PerlShr/Share\n"; close $opt_fh; my $incdirs = $ccflags =~ s{ /inc[^=]+ (?:=)+ (?:\()? ( [^\/\)]* ) }{}xi ? "$1,$incdir" : $incdir; push @commands, qq{$cc $ccflags $optimize /include=($incdirs) $cccdlflags $source_name /obj=$object_file}; push @commands, qq{$ld $ldflags $lddlflags=$loadable_object $object_file,$abs_basename.opt/OPTIONS,${incdir}perlshr_attr.opt/OPTIONS' $perllibs}; } else { my @extra; if ($^O eq 'MSWin32') { my $lib = '-l' . ($libperl =~ /lib([^.]+)\./)[0]; push @extra, "$abs_basename.def", $lib, $perllibs; } elsif ($^O eq 'cygwin') { push @extra, catfile($incdir, $config->get('useshrplib') ? 'libperl.dll.a' : 'libperl.a'); } elsif ($^O eq 'aix') { $lddlflags =~ s/\Q$(BASEEXT)\E/$abs_basename/; $lddlflags =~ s/\Q$(PERL_INC)\E/$incdir/; } elsif ($^O eq 'android') { push @extra, qq{"-L$incdir"}, '-lperl', $perllibs; } push @commands, qq{$cc $ccflags $optimize "-I$incdir" $cccdlflags -c $source_name -o $object_file}; push @commands, qq{$ld $object_file -o $loadable_object $lddlflags @extra}; } if ($prelinking{$^O}) { require ExtUtils::Mksymlists; ExtUtils::Mksymlists::Mksymlists(NAME => $basename, FILE => $abs_basename, IMPORTS => {}); } my $shortname = '_Loadable' . $counter++; my $package = "ExtUtils::HasCompiler::$shortname"; printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; for my $command (@commands) { print $output "$command\n" if not $args{quiet}; system $command and do { carp "Couldn't execute $command: $!"; return }; } # Skip loading when cross-compiling return 1 if exists $args{skip_load} ? $args{skip_load} : $config->get('usecrosscompile'); require DynaLoader; local @DynaLoader::dl_require_symbols = "boot_$basename"; my $handle = DynaLoader::dl_load_file(rel2abs($loadable_object), 0); if ($handle) { my $symbol = DynaLoader::dl_find_symbol($handle, "boot_$basename") or do { carp "Couldn't find boot symbol for $basename"; return }; my $compilet = DynaLoader::dl_install_xsub('__ANON__::__ANON__', $symbol, $source_name); my $ret = eval { $compilet->(); $package->exported } or carp $@; delete $ExtUtils::HasCompiler::{"$shortname\::"}; eval { DynaLoader::dl_unload_file($handle) } or carp $@; return defined $ret && $ret == 42; } else { carp "Couldn't load $loadable_object: " . DynaLoader::dl_error(); return; } } my %static_unsupported_on = map { $_ => 1 } qw/VMS aix MSWin32 cygwin/; sub can_compile_static_library { my %args = @_; my $output = $args{output} || \*STDOUT; my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; return if $config->get('useshrplib') eq 'true'; my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); my $basename = basename($source_name, '.c'); my $abs_basename = catfile($tempdir, $basename); my ($cc, $ccflags, $optimize, $ar, $full_ar, $ranlib, $archlibexp, $_o, $lib_ext) = map { $config->get($_) } qw/cc ccflags optimize ar full_ar ranlib archlibexp _o lib_ext/; my $incdir = catdir($archlibexp, 'CORE'); my $object_file = "$abs_basename$_o"; my $static_library = $abs_basename.$lib_ext; my @commands; if ($static_unsupported_on{$^O}) { return; } else { my $my_ar = length $full_ar ? $full_ar : $ar; push @commands, qq{$cc $ccflags $optimize "-I$incdir" -c $source_name -o $object_file}; push @commands, qq{$my_ar cr $static_library $object_file}; push @commands, qq{$ranlib $static_library} if $ranlib ne ':'; } my $shortname = '_Loadable' . $counter++; my $package = "ExtUtils::HasCompiler::$shortname"; printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; for my $command (@commands) { print $output "$command\n" if not $args{quiet}; system $command and do { carp "Couldn't execute $command: $!"; return }; } return 1; } sub can_compile_extension { my %args = @_; $args{config} ||= 'ExtUtils::HasCompiler::Config'; my $linktype = $args{linktype} || ($args{config}->get('usedl') ? 'dynamic' : 'static'); return $linktype eq 'static' ? can_compile_static_library(%args) : can_compile_loadable_object(%args); } sub ExtUtils::HasCompiler::Config::get { my (undef, $key) = @_; return $ENV{uc $key} || $Config{$key}; } 1; # ABSTRACT: Check for the presence of a compiler __END__ =pod =encoding UTF-8 =head1 NAME ExtUtils::HasCompiler - Check for the presence of a compiler =head1 VERSION version 0.021 =head1 SYNOPSIS use ExtUtils::HasCompiler 'can_compile_extension'; if (can_compile_extension()) { ... } else { ... } =head1 DESCRIPTION This module tries to check if the current system is capable of compiling, linking and loading an XS module. B: this is an early release, interface stability isn't guaranteed yet. =head1 FUNCTIONS =head2 can_compile_loadable_object(%opts) This checks if the system can compile, link and load a perl loadable object. It may take the following options: =over 4 =item * quiet Do not output the executed compilation commands. =item * config An L (compatible) object for configuration. =item * skip_load This causes can_compile_loadable_object to not try to load the generated object. This defaults to true on a cross-compiling perl. =back =head2 can_compile_static_library(%opts) This checks if the system can compile and link a perl static library. It does not check it it can compile a new perl with it. It may take the following options: =over 4 =item * quiet Do not output the executed compilation commands. =item * config An L (compatible) object for configuration. =back =head2 can_compile_extension(%opts) This will call either C, or C, depending on which is the default on your configuration. In addition to the arguments listed above, it can take one more optional argument: =over 4 =item * linktype This will force the linktype to be either static or dynamic. Dynamic compilation on a static perl won't work, but static libraries can be viable on a dynamic perl. =back =head1 AUTHOR Leon Timmermans =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Leon Timmermans. 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 List-SomeUtils-0.56/xt/0000775000175000017500000000000013134705504014600 5ustar autarchautarchList-SomeUtils-0.56/xt/release/0000775000175000017500000000000013134705504016220 5ustar autarchautarchList-SomeUtils-0.56/xt/release/cpan-changes.t0000644000175000017500000000034413134705504020733 0ustar autarchautarchuse 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'); }; List-SomeUtils-0.56/xt/release/meta-json.t0000644000175000017500000000006413134705504020300 0ustar autarchautarch#!perl use Test::CPAN::Meta::JSON; meta_json_ok(); List-SomeUtils-0.56/xt/author/0000775000175000017500000000000013134705504016102 5ustar autarchautarchList-SomeUtils-0.56/xt/author/00-compile.t0000644000175000017500000000260113134705504020131 0ustar autarchautarchuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.056 use Test::More; plan tests => 3; my @module_files = ( 'List/SomeUtils.pm', 'List/SomeUtils/PP.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) ); List-SomeUtils-0.56/xt/author/eol.t0000644000175000017500000000103113134705504017037 0ustar autarchautarchuse 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/List/SomeUtils.pm', 'lib/List/SomeUtils/PP.pm', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/Functions.t', 't/Import.t', 't/ab.t', 't/lib/LSU/Test/Functions.pm', 't/lib/LSU/Test/Import.pm', 't/lib/LSU/Test/ab.pm', 't/lib/Test/LSU.pm', 't/pp-only.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; List-SomeUtils-0.56/xt/author/test-version.t0000644000175000017500000000063713134705504020735 0ustar autarchautarchuse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.09 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 1, has_version => 1, multiple => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; List-SomeUtils-0.56/xt/author/portability.t0000644000175000017500000000026713134705504020634 0ustar autarchautarchuse strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; run_tests(); List-SomeUtils-0.56/xt/author/no-tabs.t0000644000175000017500000000077713134705504017643 0ustar autarchautarchuse 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/List/SomeUtils.pm', 'lib/List/SomeUtils/PP.pm', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/Functions.t', 't/Import.t', 't/ab.t', 't/lib/LSU/Test/Functions.pm', 't/lib/LSU/Test/Import.pm', 't/lib/LSU/Test/ab.pm', 't/lib/Test/LSU.pm', 't/pp-only.t' ); notabs_ok($_) foreach @files; done_testing; List-SomeUtils-0.56/xt/author/pod-coverage.t0000644000175000017500000000173613134705504020647 0ustar autarchautarch#!perl # This file was automatically generated by Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable. use Test::Pod::Coverage 1.08; use Test::More 0.88; BEGIN { if ( $] <= 5.008008 ) { plan skip_all => 'These tests require Pod::Coverage::TrustPod, which only works with Perl 5.8.9+'; } } use Pod::Coverage::TrustPod; my %skip = map { $_ => 1 } qw( List::SomeUtils::PP ); my @modules; for my $module ( all_modules() ) { next if $skip{$module}; push @modules, $module; } plan skip_all => 'All the modules we found were excluded from POD coverage test.' unless @modules; plan tests => scalar @modules; my %trustme = (); my @also_private; for my $module ( sort @modules ) { pod_coverage_ok( $module, { coverage_class => 'Pod::Coverage::TrustPod', also_private => \@also_private, trustme => $trustme{$module} || [], }, "pod coverage for $module" ); } done_testing(); List-SomeUtils-0.56/xt/author/tidyall.t0000644000175000017500000000067413134705504017736 0ustar autarchautarch# This file was automatically generated by Dist::Zilla::Plugin::Test::TidyAll v$VERSION use Test::More 0.88; BEGIN { if ( $] < 5.010 ) { plan skip_all => 'This test requires Perl version 5.010'; } } use Test::Code::TidyAll 0.24; tidyall_ok( verbose => ( exists $ENV{TEST_TIDYALL_VERBOSE} ? $ENV{TEST_TIDYALL_VERBOSE} : 1 ), jobs => ( exists $ENV{TEST_TIDYALL_JOBS} ? $ENV{TEST_TIDYALL_JOBS} : 4 ), ); done_testing; List-SomeUtils-0.56/xt/author/mojibake.t0000644000175000017500000000015113134705504020043 0ustar autarchautarch#!perl use strict; use warnings qw(all); use Test::More; use Test::Mojibake; all_files_encoding_ok(); List-SomeUtils-0.56/xt/author/pod-syntax.t0000644000175000017500000000025213134705504020372 0ustar autarchautarch#!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(); List-SomeUtils-0.56/xt/author/pod-spell.t0000644000175000017500000000162013134705504020163 0ustar autarchautarchuse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007004 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ ARRAYn Aaron Adam Anno AnnoCPAN BackPan Brad Branno Crane DROLSKY DROLSKY's Dave David EXPR Etheridge Filmer Forschinger Golden Inkster Jens KEYFUNC Karen Kennedy LMU List MULTICALL Mash Matsuno McCauley Muey PP PRs Parseval PayPal Purkis Rabbitson Rehsack Rezic Ricardo Rolsky Rolsky's Roode Siegel Signes Slaven SomeUtils Summersault TODO Tassilo Tatham Thegler Toby Tokuhiro Tom Wyant adamk arc autarch bnjf bsearchidx dagolden de drolsky ether firstidx firstres firstval glitchy jddurand jeandamiendurand jrmash lastidx lastres lastval lib listify mail minmax natatime notall onlyidx onlyres onlyval refactor rehsack rehsackATcpan rjbs sno tassilo thusly tokuhirom uniq von wyant List-SomeUtils-0.56/tidyall.ini0000644000175000017500000000136313134705504016311 0ustar autarchautarch[PerlCritic] select = **/*.{pl,pm,t,psgi} ignore = .build/**/* ignore = List-SomeUtils-*/**/* ignore = blib/**/* ignore = inc/**/* ignore = lib/List/SomeUtils/PP.pm ignore = t/**/* ignore = t/00-* ignore = t/author-* ignore = t/release-* ignore = xt/**/* argv = --profile=$ROOT/perlcriticrc [PerlTidy] select = **/*.{pl,pm,t,psgi} ignore = .build/**/* ignore = List-SomeUtils-*/**/* ignore = blib/**/* ignore = inc/**/* ignore = lib/List/SomeUtils/PP.pm ignore = t/**/* ignore = t/00-* ignore = t/author-* ignore = t/release-* ignore = xt/**/* argv = --profile=$ROOT/perltidyrc [Test::Vars] select = **/*.pm ignore = .build/**/* ignore = List-SomeUtils-*/**/* ignore = blib/**/* ignore = t/00-* ignore = t/author-* ignore = t/release-* ignore = xt/**/* List-SomeUtils-0.56/INSTALL0000644000175000017500000000221413134705504015173 0ustar autarchautarchThis is the Perl distribution List-SomeUtils. Installing List-SomeUtils is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm List::SomeUtils If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan List::SomeUtils ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib ## Documentation List-SomeUtils documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc List::SomeUtils List-SomeUtils-0.56/Changes0000644000175000017500000003647613134705504015456 0ustar autarchautarchRevision history for Perl extension List-SomeUtils 0.56 2017-07-22 - Make sure we depend on the latest LSU::XS if the system support XS. 0.55 2017-07-22 - Fixed incorrect comments in doc examples for uniq(). - Added a new function, mode(), requested by Jerrad Pierce. GH #2. 0.54 2017-06-01 - Moved issue tracking to GitHub. 0.53 2016-08-14 - Replaced Exporter::Tiny with Exporter. 0.52 2016-05-06 - Updated to latest ExtUtils::HasCompiler and simplified dynamic prereqs. Patch by Karen Etheridge. GitHub #3. 0.51 2016-02-27 - No code changes. The last release was missing a Changes entry. 0.50 2016-02-27 - This is List::MoreUtils under a different name with fewer configure-time prereqs. - The "import as old versions" feature present in LMU does not exist in this distribution. 0.413 2015-06-10 - Fix compiling in c++ mode (depreciated, but some people seem to require it). Solves RT#104690 0.412 2015-05-19 - release 0.411_001 without further changes 0.411_001 2015-05-11 - move generation of test endpoints to author stage as requested per issue/#9 - add a rough guide for contributors - fix rt#103251 to avoid removing bundled stuff by accident - Fix compilation errors under cl (Thanks to jddurand) 0.410 2015-03-30 - release 0.409_003 after no further issues came up 0.409_003 2015-03-27 - update bundled bootstrap modules * Data::Tumbler to 0.010 * Test::WriteVariants to 0.012 * Config::AutoConf to 0.311 - fix spelling (and add stop-words for names etc. in author tests) 0.409_002 2015-03-23 - fix multiple mg_get can break weird tie's (thanks to leont) - fix test run using PERL5OPT=d:Confess (thanks kentl & ribasushi) - use base instead of parent, cause parent isn't bundled before 5.10.1 (smoke report from SREZIC) - update bundled modules (for bootstrapping) and ppport.h (from 3.25 to 3.31) 0.409_001 2015-03-21 - fix RT#102885: uniq bug broke tied array (reported by louying@pwrd.com) - fix issue/8: Macros introduced in dfd851147f cause problems with MSVC (reported by A. Sinan Unur) - Update ppport.h from 3.25 to 3.31 0.408 2015-03-18 - fix RT#102840: uniq broken for call-by-function-return (reported by Jean-Damien Durand), with a new test case thanks to Thomas Sibley - fix RT#102853: hent_val accesses (reported by Brad Forschinger with a reasonable patch) - fix RT#102833: Compilation error with perl 5.21.7+ (reported by Slaven Rezic) - fix regex for RT#44518 test 0.407 2015-03-17 - Added one(), onlyidx(), onlyval() (RT#73134, MHASCH) and onlyres() - improve XS maintainability - document how uniq/distinct deal with undef (RT#49800) - add bsearchidx to satisfy RT#63470 - add singleton to satisfy RT#94382 - fix RT#82039 - uniq changes the type of its arguments - fix RT#44518 again 0.406 2015-03-03 - add new functions firstres and lastres in addition to firstidx, lastidx, firstval and lastval - regenerate MANIFEST to bundle README.md 0.405 2015-02-14 - fix RT#78527 - first_val/last_val in documentation - fix RT#102055 - ExtUtils::MakeMaker required version absurdly high - update README (deploy it as README.md now) - fix compiler issue for older/ansi-c89 compilers - remove local compat workarounds in favour for ppport.h 0.404 2015-01-28 - fix ancient toolchains (PREREQ_PM & Co. set appropriately), reported by ilmari - bump version required of Test::More to 0.96 (#toolchain calls it a "sane subset") - fix some meta-data #toolchain pointed out 0.403 2015-01-27 - remove most recent stable perl recommendation from meta to workaround misbehaving CPAN clients blocking update - update copyright date - ensure AUTHOR is a string on older toolchains 0.402 2014-12-17 - bump Config::AutoConf and Test::WriteVariants requirement for improved 5.6 compatibility (fixes rt#101121) - use base instead of parent in configure stage (improves building on 5.6) - fix rt#101067 by applying patch from Father Chrysostomos (thanks to Lukas Mai (MAUKE) for reporting and explaining) 0.401 2014-12-08 - update bundled Config::AutoConf to 0.307 - release after long testing period 0.400_010 2014-12-08 - bundle configure_requires using inc::latest - fix RT#96596 by checking types before starting logic ... * RT#86260 reported the same issue - lower minimum perl required to 5.6 - switch to check_produce_loadable_xs_build of Config::AutoConf 0.306 0.400_009 2014-05-05 - improve documentation (David Golden, Jens Rehsack) - bundle non-core modules (compared to 5.14) 0.400_008 2014-04-24 - fix none for 0.24 and clarify API tag documentation (David Golden) - refactor import tags for clarity (David Golden) 0.400_007 2014-04-22 - cut out exporter-related cruft; it was only necessary when needing to choose between multiple implementations (Toby Inkster) - Reorganize and clarify documentation (David Golden) - revise SYNOPSIS and DESCRIPTION for revised export model (David Golden) - introduce ":like_*" import tags (Toby Inkster, Jens Rehsack) - remove Data::Tumbler and Module::Pluggable from configure dependencies, they're coming with Test::WriteVariants 0.400_006 2014-04-01 - fix typos in POD (RT#87490 - thanks to David Steinbrunner) - refactor LMU as discussed with David Golden, Tim Bunce and Toby Inkster 0.400_005 2014-03-24 - rename implementations from alias => relax and tassilo => strict - remove 'sno' implementation - add precedence 'default' in addition to 'all' for those who prefer strict over relax - move dependency Module::Runtime from configure to runtime 0.400_004 2014-03-21 - Switch from Sub::Exporter to Exporter::Tiny (Toby Inkster) - fix issues on older perls back to 5.8.1 (Config::AutoConf will not do out of the box, but this can be fixed) - fix backward compatibility issues (RT#94013 in conjunction with RT#93995) Details needs to be discussed with Moose community (unless they stop caring) to get out of distinguishing hell as soon as possible - fix some spelling issues reported by David Steinbrunner (RT#86347) - clarify depedencies, especially recommended ones - add some additional tests to prove reported bugs (informed reporters when not reproducable) 0.400_003 2014-03-18 - fix compile error on threaded perls (RT#93934 - thanks Andreas Koenig for reporting) - fix exporter configuration (RT#93929 - thanks Andreas Koenig for reporting) - fix RT#40905 by allowing choose an appropriate implementation - add test for RT#76749 - seems not reproducable (but hopefully reporter David J. Oswald can fix the test to help fixing the issue beyond) 0.400_002 2014-03-16 - reduce minimum perl version to 5.8.1 - split implementations between existing authors - switch to DynaLoader and Sub::Exporter - rely for testing on Test::WriteVariants and Data::Tumbler (DBI::Test technology to improve tests) - fix 64-bit integer precision (RT#93207 reported by Dana Jacobsen) 0.400_001 2013-10-11 - Reformat Changes as per CPAN::Changes::Spec - taking FIRSTCOME power and move repository to GitHub - merge Tassilo's 0.25_nn dev releases back * mark "any" and "all" as "to be discussed" ==> API changes made by Alias/ADAMK - bump version to clarify new age (contributors welcome!) - bump minimum perl version to 5.8.3 0.33 2011-08-04 - Updated can_xs to fix a bug in it 0.32 2011-05-20 - Production release, no other changes 0.31_02 2011-03-21 - More accurate detection of XS support (ADAMK) 0.31_01 2011-03-21 - Updating copyright year (ADAMK) - Teak documentation of all() and none() (WYANT) - Memory leak fixed for apply() and XS version restored (ARC) - Memory leak fixed for indexes() and XS version restored (ARC) - Memory leak fixed for part() and XS version restored (ARC) 0.30 2010-12-16 - Change the way we localise PERL_DL_NONLAZY to false to remove a warning that some people were seeing. The new approach is taken from the way that List::Util does it. 0.29 2010-12-08 - Removed an erroneous Test::NoWarnings dependency 0.28 2010-12-07 - Switching to a production release - Restored the regression test for RT #38630 from 0.23. As apply() was disabled in 0.27_04 this test will only act to validate the future XS restoration of apply(). - Adding uniq warning tests, disabled initially 0.27_04 2010-12-06 - The behaviour of any/all/none/notall has changed when passed a null list to treat a null list as a legitimate list. Instead of returning C the functions now return the following: any {} == false, all {} == true, none {} == true, notall {} == false. Resolves #40905: Returning undef when none is passed an empty - Disabled the leaking XS versions of part(), apply() and indexes() 0.27_03 2010-12-06 - General house cleaning 0.27_02 2010-12-01 - Reduced test suite peak memory consumption by 5-10 meg - Added the 'distinct' alias for the uniq function, for people that like their chained map/grep/sort pipelines with a SQL'ish flavour. - Expanded test suite for the any() group of functions. - The any() group of functions now strictly always return scalar boolean true, false and undef to match the XS version. 0.27_01 2012-12-01 - Refactored the split test scripts into a common test module to be shared between both the Perl and XS versions. - Reapply fix for http://rt.cpan.org/Ticket/Display.html?id=39847 "minmax error: unpredictable results with lists of 1 element" 0.26 2010-11-23 - No changes - Some parts of the CPAN cloud were confusing my 0.24 release with the older deleted 0.24. Bumping version past Tassilo's to clarify things. 0.24 2010-11-22 - No changes, switching to a production version 0.23_01 2010-09-25 - First attempt at repackaging the List::SomeUtils code in Makefile.PL and release toolchain similar to Params::Util 0.25_02 2009-08-01 - MS VC++ 7 doesn't like inline nor 'long long' (patch provided by Taro Nishino (taro DOT nishino AT gmail.com) - Newx isbn't around in older perls so use New(0,...) instead 0.25_01 2009-07-30 - it seems the only way of handling the stack that works on all flavors of the multicall API is by making a shallow copy of it and use that between the PUSH/POP_MULTICALL bracket - fix awkward ok() override in List-SomeUtils.t so that it reports line numbers in test failures properly 0.24 2009-07-19 - List::SomeUtils was not handling the stack properly when the stack was grown from inside code-references - a couple of tests for each_arrayref were calling each_array 0.23 2009-04-19 - BACKWARDS INCOMPATIBLE CHANGE: fixed: Returning undef when none is passed an empty array is counterintuitive (http://rt.cpan.org/Ticket/Display.html?id=40905) - fixed: minmax error: unpredictable results with lists of 1 element (http://rt.cpan.org/Ticket/Display.html?id=39847) - fixed: bug: uniq doesn't like undef values. uniq warns on undef values (http://rt.cpan.org/Ticket/Display.html?id=37533) (http://rt.cpan.org/Ticket/Display.html?id=43214) - fixed: bug in pairwise when $a and $b are lexically defined using my (http://rt.cpan.org/Ticket/Display.html?id=44518) - fixed: Big memory leak with XS part() (http://rt.cpan.org/Ticket/Display.html?id=41097) - fixed: memory leak in indexes() [XS] (http://rt.cpan.org/Public/Bug/Display.html?id=41494) - reduced memory-requirements for the part() tests as that was responsible for a lot of unnecessary test-failures - new function bsearch() which performs a binary search 0.22 2006-07-02 - SvPV_nolen doesn't exist on pre 5.6 perls 0.21 2006-06-18 - propagate dies from inside the code-reference of pairwise to caller 0.20 2006-04-25 - part() would destroy the list elements when changing an array in place (@list = part { ... } @list) 0.19 2006-03-13 - working down myself the queue of suggestions: part() added (Ricardo SIGNES ) 0.18 2006-02-25 - each_arrayref (XS) couldn't deal with refs to list literals (brought up by David Filmer in comp.lang.perl.misc) 0.17 2005-12-07 - each_arrayref had no XS implementation and wasn't mentioned in the PODs (patch by Anno Siegel ) 0.16 2005-11-14 - a dangling semicolon in some macros prevented the XS portion to compile on some compilers (Lars Thegler ) 0.15 2005-11-11 - 0.13 and 0.14 broke the module on 5.6.x (spotted by Thomas A. Lowery ) - internals changed to make use of the new MULTICALL API which had to be backported to 5.005_x 0.14 2005-11-10 - 0.13 fixed the leaks but rendered the XS part uncompilable for perls < 5.6.0: Fixed (spotted by Lars Thegler ) 0.13 2005-11-09 - nearly all functions receiving a CODE-block as first argument had a hefty memory-leak: Fixed (spotted by Thomas A. Lowery ) 0.12 2005-09-28 - first_index and each_arrayref weren't exportable (spotted by Darren Duncan) 0.11 2005-09-27 - make sure that Test::Pod and Test::Pod::Coverage are installed in the required minimum versions (thanks to Ricardo Signes ) 0.10 2005-04-01 - new function minmax() with comparisons in O(3n/2 - 2) - some POD corrections (Adam Kennedy) - POD- and POD-coverage tests 0.09 2004-12-04 - 0.08 only fixed uniq() for scalar context 0.08 2004-12-03 - uniq() was not mentioned in the perldocs and only had the XS implementation - uniq() also produced wrong results on 5.8.0 (thanks to Slaven Rezic for spotting it and suggesting a workaround) - the test-suite triggered a bug in 5.6.x perls - the test-suite now tests both the XS- and Perl-implementation - a wrong example in the perldocs fixed (Ron Savage) 0.07 2004-12-01 - new functions: after, after_incl, before, before_incl, indexes lastval, firstval, pairwise, each_array, natatime, mesh (all from Eric J. Roodes' List::MoreUtil). 0.06 2004-11-14 - new function 'apply' on behalf of Brian McCauley () 0.05 2004-09-18 - merged in insert_after() and insert_after_string() from List::Utils which is now obsolete (thanks to James Keenan and Terrence Brannon ) 0.04 2004-07-10 - renamed to List::SomeUtils on suggestion by Steve Purkis 0.03 2004-07-09 - some compilers don't like the stale goto labels without any statement following. Fixed. (Robert Rothenberg ) 0.02 2004-07-08 - added Perl implementations of all functions as a fallback (Adam Kennedy ) 0.01 2004-07-05 - original version; created by h2xs 1.23 with options -b 5.5.3 -A -n List::Any List-SomeUtils-0.56/README.md0000644000175000017500000006050013134705504015423 0ustar autarchautarch# NAME List::SomeUtils - Provide the stuff missing in List::Util # VERSION version 0.56 # SYNOPSIS # import specific functions use List::SomeUtils qw( any uniq ); if ( any {/foo/} uniq @has_duplicates ) { # do stuff } # import everything use List::SomeUtils ':all'; # DESCRIPTION **List::SomeUtils** provides some trivial but commonly needed functionality on lists which is not going to go into [List::Util](https://metacpan.org/pod/List::Util). All of the below functions are implementable in only a couple of lines of Perl code. Using the functions from this module however should give slightly better performance as everything is implemented in C. The pure-Perl implementation of these functions only serves as a fallback in case the C portions of this module couldn't be compiled on this machine. # WHY DOES THIS MODULE EXIST? You might wonder why this module exists when we already have [List::MoreUtils](https://metacpan.org/pod/List::MoreUtils). In fact, this module is (nearly) the same code as is found in LMU with no significant changes. However, the LMU distribution depends on several modules for configuration (to run the Makefile.PL) that some folks in the Perl community don't think are appropriate for a module high upstream in the CPAN river. I (Dave Rolsky) don't have a strong opinion on this, but I _do_ like the functions provided by LMU, and I'm tired of getting patches and PRs to remove LMU from my code. This distribution exists to let me use the functionality I like without having to get into tiring arguments about issues I don't really care about. # EXPORTS ## Default behavior Nothing by default. To import all of this module's symbols use the `:all` tag. Otherwise functions can be imported by name as usual: use List::SomeUtils ':all'; use List::SomeUtils qw{ any firstidx }; Because historical changes to the API might make upgrading List::SomeUtils difficult for some projects, the legacy API is available via special import tags. # FUNCTIONS ## Junctions ### _Treatment of an empty list_ There are two schools of thought for how to evaluate a junction on an empty list: - Reduction to an identity (boolean) - Result is undefined (three-valued) In the first case, the result of the junction applied to the empty list is determined by a mathematical reduction to an identity depending on whether the underlying comparison is "or" or "and". Conceptually: "any are true" "all are true" -------------- -------------- 2 elements: A || B || 0 A && B && 1 1 element: A || 0 A && 1 0 elements: 0 1 In the second case, three-value logic is desired, in which a junction applied to an empty list returns `undef` rather than true or false Junctions with a `_u` suffix implement three-valued logic. Those without are boolean. ### all BLOCK LIST ### all\_u BLOCK LIST Returns a true value if all items in LIST meet the criterion given through BLOCK. Sets `$_` for each item in LIST in turn: print "All values are non-negative" if all { $_ >= 0 } ($x, $y, $z); For an empty LIST, `all` returns true (i.e. no values failed the condition) and `all_u` returns `undef`. Thus, `all_u(@list)` is equivalent to `@list ? all(@list) : undef`. **Note**: because Perl treats `undef` as false, you must check the return value of `all_u` with `defined` or you will get the opposite result of what you expect. ### any BLOCK LIST ### any\_u BLOCK LIST Returns a true value if any item in LIST meets the criterion given through BLOCK. Sets `$_` for each item in LIST in turn: print "At least one non-negative value" if any { $_ >= 0 } ($x, $y, $z); For an empty LIST, `any` returns false and `any_u` returns `undef`. Thus, `any_u(@list)` is equivalent to `@list ? any(@list) : undef`. ### none BLOCK LIST ### none\_u BLOCK LIST Logically the negation of `any`. Returns a true value if no item in LIST meets the criterion given through BLOCK. Sets `$_` for each item in LIST in turn: print "No non-negative values" if none { $_ >= 0 } ($x, $y, $z); For an empty LIST, `none` returns true (i.e. no values failed the condition) and `none_u` returns `undef`. Thus, `none_u(@list)` is equivalent to `@list ? none(@list) : undef`. **Note**: because Perl treats `undef` as false, you must check the return value of `none_u` with `defined` or you will get the opposite result of what you expect. ### notall BLOCK LIST ### notall\_u BLOCK LIST Logically the negation of `all`. Returns a true value if not all items in LIST meet the criterion given through BLOCK. Sets `$_` for each item in LIST in turn: print "Not all values are non-negative" if notall { $_ >= 0 } ($x, $y, $z); For an empty LIST, `notall` returns false and `notall_u` returns `undef`. Thus, `notall_u(@list)` is equivalent to `@list ? notall(@list) : undef`. ### one BLOCK LIST ### one\_u BLOCK LIST Returns a true value if precisely one item in LIST meets the criterion given through BLOCK. Sets `$_` for each item in LIST in turn: print "Precisely one value defined" if one { defined($_) } @list; Returns false otherwise. For an empty LIST, `one` returns false and `one_u` returns `undef`. The expression `one BLOCK LIST` is almost equivalent to `1 == true BLOCK LIST`, except for short-cutting. Evaluation of BLOCK will immediately stop at the second true value. ## Transformation ### apply BLOCK LIST Applies BLOCK to each item in LIST and returns a list of the values after BLOCK has been applied. In scalar context, the last element is returned. This function is similar to `map` but will not modify the elements of the input list: my @list = (1 .. 4); my @mult = apply { $_ *= 2 } @list; print "\@list = @list\n"; print "\@mult = @mult\n"; __END__ @list = 1 2 3 4 @mult = 2 4 6 8 Think of it as syntactic sugar for for (my @mult = @list) { $_ *= 2 } ### insert\_after BLOCK VALUE LIST Inserts VALUE after the first item in LIST for which the criterion in BLOCK is true. Sets `$_` for each item in LIST in turn. my @list = qw/This is a list/; insert_after { $_ eq "a" } "longer" => @list; print "@list"; __END__ This is a longer list ### insert\_after\_string STRING VALUE LIST Inserts VALUE after the first item in LIST which is equal to STRING. my @list = qw/This is a list/; insert_after_string "a", "longer" => @list; print "@list"; __END__ This is a longer list ### pairwise BLOCK ARRAY1 ARRAY2 Evaluates BLOCK for each pair of elements in ARRAY1 and ARRAY2 and returns a new list consisting of BLOCK's return values. The two elements are set to `$a` and `$b`. Note that those two are aliases to the original value so changing them will modify the input arrays. @a = (1 .. 5); @b = (11 .. 15); @x = pairwise { $a + $b } @a, @b; # returns 12, 14, 16, 18, 20 # mesh with pairwise @a = qw/a b c/; @b = qw/1 2 3/; @x = pairwise { ($a, $b) } @a, @b; # returns a, 1, b, 2, c, 3 ### mesh ARRAY1 ARRAY2 \[ ARRAY3 ... \] ### zip ARRAY1 ARRAY2 \[ ARRAY3 ... \] Returns a list consisting of the first elements of each array, then the second, then the third, etc, until all arrays are exhausted. Examples: @x = qw/a b c d/; @y = qw/1 2 3 4/; @z = mesh @x, @y; # returns a, 1, b, 2, c, 3, d, 4 @a = ('x'); @b = ('1', '2'); @c = qw/zip zap zot/; @d = mesh @a, @b, @c; # x, 1, zip, undef, 2, zap, undef, undef, zot `zip` is an alias for `mesh`. ### uniq LIST ### distinct LIST Returns a new list by stripping duplicate values in LIST by comparing the values as hash keys, except that undef is considered separate from ''. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 # returns "Mike", "Michael", "Richard", "Rick" my @n = distinct "Mike", "Michael", "Richard", "Rick", "Michael", "Rick" # returns '', undef, 'S1', A5' my @s = distinct '', undef, 'S1', 'A5' # returns '', undef, 'S1', A5' my @w = uniq undef, '', 'S1', 'A5' `distinct` is an alias for `uniq`. **RT#49800** can be used to give feedback about this behavior. ### singleton Returns a new list by stripping values in LIST occurring more than once by comparing the values as hash keys, except that undef is considered separate from ''. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of elements occurring only once in LIST. my @x = singleton 1,1,2,2,3,4,5 # returns 3 4 5 ## Partitioning ### after BLOCK LIST Returns a list of the values of LIST after (and not including) the point where BLOCK returns a true value. Sets `$_` for each element in LIST in turn. @x = after { $_ % 5 == 0 } (1..9); # returns 6, 7, 8, 9 ### after\_incl BLOCK LIST Same as `after` but also includes the element for which BLOCK is true. ### before BLOCK LIST Returns a list of values of LIST up to (and not including) the point where BLOCK returns a true value. Sets `$_` for each element in LIST in turn. ### before\_incl BLOCK LIST Same as `before` but also includes the element for which BLOCK is true. ### part BLOCK LIST Partitions LIST based on the return value of BLOCK which denotes into which partition the current value is put. Returns a list of the partitions thusly created. Each partition created is a reference to an array. my $i = 0; my @part = part { $i++ % 2 } 1 .. 8; # returns [1, 3, 5, 7], [2, 4, 6, 8] You can have a sparse list of partitions as well where non-set partitions will be undef: my @part = part { 2 } 1 .. 10; # returns undef, undef, [ 1 .. 10 ] Be careful with negative values, though: my @part = part { -1 } 1 .. 10; __END__ Modification of non-creatable array value attempted, subscript -1 ... Negative values are only ok when they refer to a partition previously created: my @idx = ( 0, 1, -1 ); my $i = 0; my @part = part { $idx[$++ % 3] } 1 .. 8; # [1, 4, 7], [2, 3, 5, 6, 8] ## Iteration ### each\_array ARRAY1 ARRAY2 ... Creates an array iterator to return the elements of the list of arrays ARRAY1, ARRAY2 throughout ARRAYn in turn. That is, the first time it is called, it returns the first element of each array. The next time, it returns the second elements. And so on, until all elements are exhausted. This is useful for looping over more than one array at once: my $ea = each_array(@a, @b, @c); while ( my ($a, $b, $c) = $ea->() ) { .... } The iterator returns the empty list when it reached the end of all arrays. If the iterator is passed an argument of '`index`', then it returns the index of the last fetched set of values, as a scalar. ### each\_arrayref LIST Like each\_array, but the arguments are references to arrays, not the plain arrays. ### natatime EXPR, LIST Creates an array iterator, for looping over an array in chunks of `$n` items at a time. (n at a time, get it?). An example is probably a better explanation than I could give in words. Example: my @x = ('a' .. 'g'); my $it = natatime 3, @x; while (my @vals = $it->()) { print "@vals\n"; } This prints a b c d e f g ## Searching ### bsearch BLOCK LIST Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (stored in `$_`) is smaller, a positive value if it is bigger and zero if it matches. Returns a boolean value in scalar context. In list context, it returns the element if it was found, otherwise the empty list. ### bsearchidx BLOCK LIST ### bsearch\_index BLOCK LIST Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (stored in `$_`) is smaller, a positive value if it is bigger and zero if it matches. Returns the index of found element, otherwise `-1`. `bsearch_index` is an alias for `bsearchidx`. ### firstval BLOCK LIST ### first\_value BLOCK LIST Returns the first element in LIST for which BLOCK evaluates to true. Each element of LIST is set to `$_` in turn. Returns `undef` if no such element has been found. `first_value` is an alias for `firstval`. ### onlyval BLOCK LIST ### only\_value BLOCK LIST Returns the only element in LIST for which BLOCK evaluates to true. Sets `$_` for each item in LIST in turn. Returns `undef` if no such element has been found. `only_value` is an alias for `onlyval`. ### lastval BLOCK LIST ### last\_value BLOCK LIST Returns the last value in LIST for which BLOCK evaluates to true. Each element of LIST is set to `$_` in turn. Returns `undef` if no such element has been found. `last_value` is an alias for `lastval`. ### firstres BLOCK LIST ### first\_result BLOCK LIST Returns the result of BLOCK for the first element in LIST for which BLOCK evaluates to true. Each element of LIST is set to `$_` in turn. Returns `undef` if no such element has been found. `first_result` is an alias for `firstres`. ### onlyres BLOCK LIST ### only\_result BLOCK LIST Returns the result of BLOCK for the first element in LIST for which BLOCK evaluates to true. Sets `$_` for each item in LIST in turn. Returns `undef` if no such element has been found. `only_result` is an alias for `onlyres`. ### lastres BLOCK LIST ### last\_result BLOCK LIST Returns the result of BLOCK for the last element in LIST for which BLOCK evaluates to true. Each element of LIST is set to `$_` in turn. Returns `undef` if no such element has been found. `last_result` is an alias for `lastres`. ### indexes BLOCK LIST Evaluates BLOCK for each element in LIST (assigned to `$_`) and returns a list of the indices of those elements for which BLOCK returned a true value. This is just like `grep` only that it returns indices instead of values: @x = indexes { $_ % 2 == 0 } (1..10); # returns 1, 3, 5, 7, 9 ### firstidx BLOCK LIST ### first\_index BLOCK LIST Returns the index of the first element in LIST for which the criterion in BLOCK is true. Sets `$_` for each item in LIST in turn: my @list = (1, 4, 3, 2, 4, 6); printf "item with index %i in list is 4", firstidx { $_ == 4 } @list; __END__ item with index 1 in list is 4 Returns `-1` if no such item could be found. `first_index` is an alias for `firstidx`. ### onlyidx BLOCK LIST ### only\_index BLOCK LIST Returns the index of the only element in LIST for which the criterion in BLOCK is true. Sets `$_` for each item in LIST in turn: my @list = (1, 3, 4, 3, 2, 4); printf "uniqe index of item 2 in list is %i", onlyidx { $_ == 2 } @list; __END__ unique index of item 2 in list is 4 Returns `-1` if either no such item or more than one of these has been found. `only_index` is an alias for `onlyidx`. ### lastidx BLOCK LIST ### last\_index BLOCK LIST Returns the index of the last element in LIST for which the criterion in BLOCK is true. Sets `$_` for each item in LIST in turn: my @list = (1, 4, 3, 2, 4, 6); printf "item with index %i in list is 4", lastidx { $_ == 4 } @list; __END__ item with index 4 in list is 4 Returns `-1` if no such item could be found. `last_index` is an alias for `lastidx`. ## Sorting ### sort\_by BLOCK LIST Returns the list of values sorted according to the string values returned by the KEYFUNC block or function. A typical use of this may be to sort objects according to the string value of some accessor, such as sort_by { $_->name } @people The key function is called in scalar context, being passed each value in turn as both $\_ and the only argument in the parameters, @\_. The values are then sorted according to string comparisons on the values returned. This is equivalent to sort { $a->name cmp $b->name } @people except that it guarantees the name accessor will be executed only once per value. One interesting use-case is to sort strings which may have numbers embedded in them "naturally", rather than lexically. sort_by { s/(\d+)/sprintf "%09d", $1/eg; $_ } @strings This sorts strings by generating sort keys which zero-pad the embedded numbers to some level (9 digits in this case), helping to ensure the lexical sort puts them in the correct order. ### nsort\_by BLOCK LIST Similar to sort\_by but compares its key values numerically. ## Counting and calculation ### true BLOCK LIST Counts the number of elements in LIST for which the criterion in BLOCK is true. Sets `$_` for each item in LIST in turn: printf "%i item(s) are defined", true { defined($_) } @list; ### false BLOCK LIST Counts the number of elements in LIST for which the criterion in BLOCK is false. Sets `$_` for each item in LIST in turn: printf "%i item(s) are not defined", false { defined($_) } @list; ### minmax LIST Calculates the minimum and maximum of LIST and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if LIST was empty. The `minmax` algorithm differs from a naive iteration over the list where each element is compared to two values being the so far calculated min and max value in that it only requires 3n/2 - 2 comparisons. Thus it is the most efficient possible algorithm. However, the Perl implementation of it has some overhead simply due to the fact that there are more lines of Perl code involved. Therefore, LIST needs to be fairly big in order for `minmax` to win over a naive implementation. This limitation does not apply to the XS version. ### mode LIST Calculates the most common items in the list and returns them as a list. This is effectively done by string comparisons, so references will be stringified. If they implement string overloading, this will be used. If more than one item appears the same number of times in the list, all such items will be returned. For example, the mode of a unique list is the list itself. This function **always** returns a list. That means that in scalar context you get a count indicating the number of modes in the list. # MAINTENANCE The maintenance goal is to preserve the documented semantics of the API; bug fixes that bring actual behavior in line with semantics are allowed. New API functions may be added over time. If a backwards incompatible change is unavoidable, we will attempt to provide support for the legacy API using the same export tag mechanism currently in place. This module attempts to use few non-core dependencies. Non-core configuration and testing modules will be bundled when reasonable; run-time dependencies will be added only if they deliver substantial benefit. # KNOWN ISSUES There is a problem with a bug in 5.6.x perls. It is a syntax error to write things like: my @x = apply { s/foo/bar/ } qw{ foo bar baz }; It has to be written as either my @x = apply { s/foo/bar/ } 'foo', 'bar', 'baz'; or my @x = apply { s/foo/bar/ } my @dummy = qw/foo bar baz/; Perl 5.5.x and Perl 5.8.x don't suffer from this limitation. If you have a functionality that you could imagine being in this module, please drop me a line. This module's policy will be less strict than [List::Util](https://metacpan.org/pod/List::Util)'s when it comes to additions as it isn't a core module. When you report bugs, it would be nice if you could additionally give me the output of your program with the environment variable `LIST_MOREUTILS_PP` set to a true value. That way I know where to look for the problem (in XS, pure-Perl or possibly both). # THANKS ## Tassilo von Parseval Credits go to a number of people: Steve Purkis for giving me namespace advice and James Keenan and Terrence Branno for their effort of keeping the CPAN tidier by making [List::Util](https://metacpan.org/pod/List::Util) obsolete. Brian McCauley suggested the inclusion of apply() and provided the pure-Perl implementation for it. Eric J. Roode asked me to add all functions from his module `List::SomeUtil` into this one. With minor modifications, the pure-Perl implementations of those are by him. The bunch of people who almost immediately pointed out the many problems with the glitchy 0.07 release (Slaven Rezic, Ron Savage, CPAN testers). A particularly nasty memory leak was spotted by Thomas A. Lowery. Lars Thegler made me aware of problems with older Perl versions. Anno Siegel de-orphaned each\_arrayref(). David Filmer made me aware of a problem in each\_arrayref that could ultimately lead to a segfault. Ricardo Signes suggested the inclusion of part() and provided the Perl-implementation. Robin Huston kindly fixed a bug in perl's MULTICALL API to make the XS-implementation of part() work. ## Jens Rehsack Credits goes to all people contributing feedback during the v0.400 development releases. Special thanks goes to David Golden who spent a lot of effort to develop a design to support current state of CPAN as well as ancient software somewhere in the dark. He also contributed a lot of patches to refactor the API frontend to welcome any user of List::SomeUtils - from ancient past to recently last used. Toby Inkster provided a lot of useful feedback for sane importer code and was a nice sounding board for API discussions. Peter Rabbitson provided a sane git repository setup containing entire package history. # TODO A pile of requests from other people is still pending further processing in my mailbox. This includes: - List::Util export pass-through Allow **List::SomeUtils** to pass-through the regular [List::Util](https://metacpan.org/pod/List::Util) functions to end users only need to `use` the one module. - uniq\_by(&@) Use code-reference to extract a key based on which the uniqueness is determined. Suggested by Aaron Crane. - delete\_index - random\_item - random\_item\_delete\_index - list\_diff\_hash - list\_diff\_inboth - list\_diff\_infirst - list\_diff\_insecond These were all suggested by Dan Muey. - listify Always return a flat list when either a simple scalar value was passed or an array-reference. Suggested by Mark Summersault. # SEE ALSO [List::Util](https://metacpan.org/pod/List::Util), [List::AllUtils](https://metacpan.org/pod/List::AllUtils), [List::UtilsBy](https://metacpan.org/pod/List::UtilsBy) # HISTORICAL COPYRIGHT Some parts copyright 2011 Aaron Crane. Copyright 2004 - 2010 by Tassilo von Parseval Copyright 2013 - 2015 by Jens Rehsack # SUPPORT Bugs may be submitted at [https://github.com/houseabsolute/List-SomeUtils/issues](https://github.com/houseabsolute/List-SomeUtils/issues). I am also usually active on IRC as 'autarch' on `irc://irc.perl.org`. # SOURCE The source code repository for List-SomeUtils can be found at [https://github.com/houseabsolute/List-SomeUtils](https://github.com/houseabsolute/List-SomeUtils). # DONATIONS If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer. Please note that **I am not suggesting that you must do this** in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me. Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together). To donate, log into PayPal and send money to autarch@urth.org, or use the button at [http://www.urth.org/~autarch/fs-donation.html](http://www.urth.org/~autarch/fs-donation.html). # AUTHORS - Tassilo von Parseval - Adam Kennedy - Jens Rehsack - Dave Rolsky # CONTRIBUTORS - Aaron Crane - BackPan - Brad Forschinger - David Golden - jddurand - Jens Rehsack - J.R. Mash - Karen Etheridge - Ricardo Signes - Toby Inkster - Tokuhiro Matsuno - Tom Wyant # COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Dave Rolsky . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of the license can be found in the `LICENSE` file included with this distribution. List-SomeUtils-0.56/MANIFEST0000644000175000017500000000135513134705504015300 0ustar autarchautarch# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.010. CONTRIBUTING.md Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README.md cpanfile dist.ini inc/ExtUtils/HasCompiler.pm lib/List/SomeUtils.pm lib/List/SomeUtils/PP.pm perlcriticrc perltidyrc t/00-report-prereqs.dd t/00-report-prereqs.t t/Functions.t t/Import.t t/ab.t t/lib/LSU/Test/Functions.pm t/lib/LSU/Test/Import.pm t/lib/LSU/Test/ab.pm t/lib/Test/LSU.pm t/pp-only.t tidyall.ini xt/author/00-compile.t xt/author/eol.t xt/author/mojibake.t xt/author/no-tabs.t xt/author/pod-coverage.t xt/author/pod-spell.t xt/author/pod-syntax.t xt/author/portability.t xt/author/test-version.t xt/author/tidyall.t xt/release/cpan-changes.t xt/release/meta-json.t List-SomeUtils-0.56/CONTRIBUTING.md0000644000175000017500000001007613134705504016400 0ustar autarchautarch# CONTRIBUTING Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. Please note that if you have any questions or difficulties, you can reach the maintainer(s) through the bug queue described later in this document (preferred), or by emailing the releaser directly. You are not required to follow any of the steps in this document to submit a patch or bug report; these are just recommendations, intended to help you (and help us help you faster). The distribution is managed with [Dist::Zilla](https://metacpan.org/release/Dist-Zilla). However, you can still compile and test the code with the `Makefile.PL` or `Build.PL` in the repository: perl Makefile.PL make make test or perl Build.PL ./Build ./Build test As well as: $ prove -bvr t or $ perl -Mblib t/some_test_file.t You may need to satisfy some dependencies. The easiest way to satisfy dependencies is to install the last release. This is available at https://metacpan.org/release/List-SomeUtils If you use cpanminus, you can do it without downloading the tarball first: $ cpanm --reinstall --installdeps --with-recommends List::SomeUtils Dist::Zilla is a very powerful authoring tool, but requires a number of author-specific plugins. If you would like to use it for contributing, install it from CPAN, then run one of the following commands, depending on your CPAN client: $ cpan `dzil authordeps --missing` or $ dzil authordeps --missing | cpanm They may also be additional requirements not needed by the dzil build which are needed for tests or other development: $ cpan `dzil listdeps --author --missing` or $ dzil listdeps --author --missing | cpanm Or, you can use the 'dzil stale' command to install all requirements at once: $ cpan Dist::Zilla::App::Command::stale $ cpan `dzil stale --all` or $ cpanm Dist::Zilla::App::Command::stale $ dzil stale --all | cpanm You can also do this via cpanm directly: $ cpanm --reinstall --installdeps --with-develop --with-recommends List::SomeUtils Once installed, here are some dzil commands you might try: $ dzil build $ dzil test $ dzil test --release $ dzil xtest $ dzil listdeps --json $ dzil build --notgz You can learn more about Dist::Zilla at http://dzil.org/. The code for this distribution is [hosted at GitHub](https://github.com/houseabsolute/List-SomeUtils). You can submit code changes by forking the repository, pushing your code changes to your clone, and then submitting a pull request. Detailed instructions for doing that is available here: https://help.github.com/articles/creating-a-pull-request If you have found a bug, but do not have an accompanying patch to fix it, you can submit an issue report [via the web](https://github.com/houseabsolute/List-SomeUtils/issues) ). This is a good place to send your questions about the usage of this distribution. ## Travis All pull requests for this distribution will be automatically tested by [Travis](https://travis-ci.org/) and the build status will be reported on the pull request page. If your build fails, please take a look at the output. ## TidyAll This distribution uses [Code::TidyAll](https://metacpan.org/release/Code-TidyAll) to enforce a uniform coding style. This is tested as part of the author testing suite. You can install and run tidyall by running the following commands: $ cpanm Code::TidyAll $ tidyall -a Please run this before committing your changes and address any issues it brings up. ## Contributor Names If you send a patch or pull request, your name and email address will be included in the documentation as a contributor (using the attribution on the commit or patch), unless you specifically request for it not to be. If you wish to be listed under a different name or address, you should submit a pull request to the .mailmap file to contain the correct mapping. This file was generated via Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.013 from a template file originating in Dist-Zilla-PluginBundle-DROLSKY-0.85. List-SomeUtils-0.56/cpanfile0000644000175000017500000000371713134705504015657 0ustar autarchautarchrequires "Carp" => "0"; requires "Exporter" => "0"; requires "List::Util" => "0"; requires "Module::Implementation" => "0"; requires "perl" => "5.006"; requires "strict" => "0"; requires "vars" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "ExtUtils::MakeMaker" => "0"; requires "File::Spec" => "0"; requires "Scalar::Util" => "0"; requires "Storable" => "0"; requires "Test::Builder::Module" => "0"; requires "Test::LeakTrace" => "0"; requires "Test::More" => "0.96"; requires "Tie::Array" => "0"; requires "base" => "0"; requires "lib" => "0"; requires "overload" => "0"; }; on 'test' => sub { recommends "CPAN::Meta" => "2.120900"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "0"; requires "Text::ParseWords" => "0"; }; on 'develop' => sub { requires "Code::TidyAll" => "0.56"; requires "Code::TidyAll::Plugin::SortLines::Naturally" => "0.000003"; requires "Code::TidyAll::Plugin::Test::Vars" => "0.02"; requires "ExtUtils::HasCompiler" => "0.014"; requires "File::Spec" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Parallel::ForkManager" => "1.19"; requires "Perl::Critic" => "1.126"; requires "Perl::Tidy" => "20160302"; requires "Pod::Coverage::TrustPod" => "0"; requires "Pod::Wordlist" => "0"; requires "Scalar::Util" => "0"; requires "Storable" => "0"; requires "Test::CPAN::Changes" => "0.19"; requires "Test::CPAN::Meta::JSON" => "0.16"; requires "Test::Code::TidyAll" => "0.50"; requires "Test::EOL" => "0"; requires "Test::LeakTrace" => "0"; requires "Test::Mojibake" => "0"; requires "Test::More" => "0.96"; requires "Test::NoTabs" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; requires "Test::Portability::Files" => "0"; requires "Test::Spelling" => "0.12"; requires "Test::Vars" => "0.009"; requires "Test::Version" => "2.05"; requires "Tie::Array" => "0"; requires "blib" => "1.01"; }; List-SomeUtils-0.56/LICENSE0000644000175000017500000004374313134705504015163 0ustar autarchautarchThis software is copyright (c) 2017 by Dave Rolsky . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system 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" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2017 by Dave Rolsky . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, 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 license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our 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. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, 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 a 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 tell them 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. 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 Agreement 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 work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 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 General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual 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 General Public License. d) 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. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 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 Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying 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. 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. 7. 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 the 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 the license, you may choose any version ever published by the Free Software Foundation. 8. 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 9. 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. 10. 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 Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2017 by Dave Rolsky . This is free software, licensed under: The Artistic License 1.0 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 List-SomeUtils-0.56/META.json0000644000175000017500000011302113134705504015562 0ustar autarchautarch{ "abstract" : "Provide the stuff missing in List::Util", "author" : [ "Tassilo von Parseval ", "Adam Kennedy ", "Jens Rehsack ", "Dave Rolsky " ], "dynamic_config" : 1, "generated_by" : "Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "List-SomeUtils", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "Text::ParseWords" : "0" } }, "develop" : { "requires" : { "Code::TidyAll" : "0.56", "Code::TidyAll::Plugin::SortLines::Naturally" : "0.000003", "Code::TidyAll::Plugin::Test::Vars" : "0.02", "ExtUtils::HasCompiler" : "0.014", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Parallel::ForkManager" : "1.19", "Perl::Critic" : "1.126", "Perl::Tidy" : "20160302", "Pod::Coverage::TrustPod" : "0", "Pod::Wordlist" : "0", "Scalar::Util" : "0", "Storable" : "0", "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta::JSON" : "0.16", "Test::Code::TidyAll" : "0.50", "Test::EOL" : "0", "Test::LeakTrace" : "0", "Test::Mojibake" : "0", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Portability::Files" : "0", "Test::Spelling" : "0.12", "Test::Vars" : "0.009", "Test::Version" : "2.05", "Tie::Array" : "0", "blib" : "1.01" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "List::Util" : "0", "Module::Implementation" : "0", "perl" : "5.006", "strict" : "0", "vars" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "Scalar::Util" : "0", "Storable" : "0", "Test::Builder::Module" : "0", "Test::LeakTrace" : "0", "Test::More" : "0.96", "Tie::Array" : "0", "base" : "0", "lib" : "0", "overload" : "0" } } }, "provides" : { "List::SomeUtils" : { "file" : "lib/List/SomeUtils.pm", "version" : "0.56" }, "List::SomeUtils::PP" : { "file" : "lib/List/SomeUtils/PP.pm", "version" : "0.56" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/houseabsolute/List-SomeUtils/issues" }, "homepage" : "http://metacpan.org/release/List-SomeUtils", "repository" : { "type" : "git", "url" : "git://github.com/houseabsolute/List-SomeUtils.git", "web" : "https://github.com/houseabsolute/List-SomeUtils" } }, "version" : "0.56", "x_Dist_Zilla" : { "perl" : { "version" : "5.024001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DROLSKY/MakeMaker", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "CONTRIBUTING.md", "LICENSE", "Makefile.PL", "README.md", "cpanfile" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@DROLSKY/Git::GatherDir", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@DROLSKY/ManifestSkip", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@DROLSKY/License", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@DROLSKY/ExecDir", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@DROLSKY/ShareDir", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@DROLSKY/Manifest", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::CheckVersionIncrement", "name" : "@DROLSKY/CheckVersionIncrement", "version" : "0.121750" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@DROLSKY/TestRelease", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@DROLSKY/ConfirmRelease", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@DROLSKY/UploadToCPAN", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::VersionFromMainModule", "name" : "@DROLSKY/VersionFromMainModule", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@DROLSKY/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@DROLSKY/AutoPrereqs", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromBuild", "name" : "@DROLSKY/CopyFilesFromBuild", "version" : "0.170880" }, { "class" : "Dist::Zilla::Plugin::GitHub::Meta", "name" : "@DROLSKY/GitHub::Meta", "version" : "0.44" }, { "class" : "Dist::Zilla::Plugin::GitHub::Update", "config" : { "Dist::Zilla::Plugin::GitHub::Update" : { "metacpan" : 1 } }, "name" : "@DROLSKY/GitHub::Update", "version" : "0.44" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@DROLSKY/MetaResources", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.010" } ], "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.000033", "version" : "0.004" } }, "name" : "@DROLSKY/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::Meta::Contributors", "name" : "@DROLSKY/Meta::Contributors", "version" : "0.003" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@DROLSKY/MetaConfig", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@DROLSKY/MetaJSON", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@DROLSKY/MetaYAML", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@DROLSKY/NextRelease", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@DROLSKY/Test::More with subtest", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@DROLSKY/Modules for use with tidyall", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@DROLSKY/Test::Version which fixes https://github.com/plicease/Test-Version/issues/7", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 0, "check_all_prereqs" : 0, "modules" : [ "Dist::Zilla::PluginBundle::DROLSKY" ], "phase" : "build", "run_under_travis" : 0, "skip" : [] } }, "name" : "@DROLSKY/Dist::Zilla::PluginBundle::DROLSKY", "version" : "0.053" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 1, "check_all_prereqs" : 1, "modules" : [], "phase" : "release", "run_under_travis" : 0, "skip" : [ "Dist::Zilla::Plugin::DROLSKY::Contributors", "Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch", "Dist::Zilla::Plugin::DROLSKY::License", "Dist::Zilla::Plugin::DROLSKY::TidyAll", "Dist::Zilla::Plugin::DROLSKY::WeaverConfig", "Pod::Weaver::PluginBundle::DROLSKY" ] } }, "name" : "@DROLSKY/PromptIfStale", "version" : "0.053" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable", "name" : "@DROLSKY/Test::Pod::Coverage::Configurable", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::Test::PodSpelling", "config" : { "Dist::Zilla::Plugin::Test::PodSpelling" : { "directories" : [ "bin", "lib" ], "spell_cmd" : "", "stopwords" : [ "ARRAYn", "ARRAYn", "Anno", "Anno", "AnnoCPAN", "AnnoCPAN", "Branno", "Branno", "DROLSKY", "DROLSKY's", "EXPR", "EXPR", "Filmer", "Filmer", "Inkster", "Jens", "KEYFUNC", "KEYFUNC", "LMU", "MULTICALL", "MULTICALL", "McCauley", "McCauley", "Muey", "Muey", "PRs", "Parseval", "PayPal", "Purkis", "Purkis", "Rabbitson", "Rabbitson", "Rehsack", "Rezic", "Rezic", "Rolsky", "Rolsky's", "Roode", "Roode", "Siegel", "Siegel", "Signes", "Slaven", "Slaven", "Summersault", "Summersault", "TODO", "TODO", "Tassilo", "Tatham", "Tatham", "Thegler", "Thegler", "bsearchidx", "bsearchidx", "de", "drolsky", "firstidx", "firstidx", "firstres", "firstres", "firstval", "firstval", "glitchy", "glitchy", "lastidx", "lastidx", "lastres", "lastres", "lastval", "lastval", "listify", "listify", "minmax", "minmax", "natatime", "natatime", "notall", "notall", "onlyidx", "onlyidx", "onlyres", "onlyres", "onlyval", "onlyval", "refactor", "refactor", "rehsackATcpan", "thusly", "thusly", "uniq", "uniq", "von" ], "wordlist" : "Pod::Wordlist" } }, "name" : "@DROLSKY/Test::PodSpelling", "version" : "2.007004" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@DROLSKY/PodSyntaxTests", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DROLSKY/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::MojibakeTests", "name" : "@DROLSKY/MojibakeTests", "version" : "0.8" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "config" : { "Dist::Zilla::Plugin::Test::CPAN::Changes" : { "changelog" : "Changes" } }, "name" : "@DROLSKY/Test::CPAN::Changes", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Meta::JSON", "name" : "@DROLSKY/Test::CPAN::Meta::JSON", "version" : "0.004" }, { "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" : "@DROLSKY/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" : "@DROLSKY/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::Portability", "config" : { "Dist::Zilla::Plugin::Test::Portability" : { "options" : "" } }, "name" : "@DROLSKY/Test::Portability", "version" : "2.001000" }, { "class" : "Dist::Zilla::Plugin::Test::TidyAll", "name" : "@DROLSKY/Test::TidyAll", "version" : "0.04" }, { "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" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "develop", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@DROLSKY/Test::Compile", "version" : "2.056" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@DROLSKY/Test::ReportPrereqs", "version" : "0.027" }, { "class" : "Dist::Zilla::Plugin::Test::Version", "name" : "@DROLSKY/Test::Version", "version" : "1.09" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::Contributors", "name" : "@DROLSKY/DROLSKY::Contributors", "version" : "0.85" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "git_version" : "2.7.4", "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", "paths" : [] } }, "name" : "@DROLSKY/Git::Contributors", "version" : "0.030" }, { "class" : "Dist::Zilla::Plugin::SurgicalPodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@DROLSKY" ], "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@DROLSKY/SingleEncoding", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@DROLSKY/List", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@DROLSKY/Verbatim", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@DROLSKY/header", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@DROLSKY/Name", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@DROLSKY/Version", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@DROLSKY/prelude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "TYPES", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@DROLSKY/Leftovers", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@DROLSKY/postlude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@DROLSKY/generate SUPPORT", "version" : "1.06" }, { "class" : "Pod::Weaver::Section::AllowOverride", "name" : "@DROLSKY/allow override SUPPORT", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@DROLSKY/generate SOURCE", "version" : "1.06" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@DROLSKY/generate DONATIONS", "version" : "1.06" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@DROLSKY/Authors", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@DROLSKY/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@DROLSKY/Legal", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@DROLSKY/footer", "version" : "4.015" } ] } }, "name" : "@DROLSKY/SurgicalPodWeaver", "version" : "0.0023" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::WeaverConfig", "name" : "@DROLSKY/DROLSKY::WeaverConfig", "version" : "0.85" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "@DROLSKY/README.md in build", "version" : "0.163250" }, { "class" : "Dist::Zilla::Plugin::GenerateFile::FromShareDir", "config" : { "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : { "destination_filename" : "CONTRIBUTING.md", "dist" : "Dist-Zilla-PluginBundle-DROLSKY", "encoding" : "UTF-8", "has_xs" : 0, "location" : "build", "source_filename" : "CONTRIBUTING.md" }, "Dist::Zilla::Role::RepoFileInjector" : { "allow_overwrite" : 1, "repo_root" : ".", "version" : "0.007" } }, "name" : "@DROLSKY/Generate CONTRIBUTING.md", "version" : "0.013" }, { "class" : "Dist::Zilla::Plugin::InstallGuide", "name" : "@DROLSKY/InstallGuide", "version" : "1.200007" }, { "class" : "Dist::Zilla::Plugin::CPANFile", "name" : "@DROLSKY/CPANFile", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::License", "name" : "@DROLSKY/DROLSKY::License", "version" : "0.85" }, { "class" : "Dist::Zilla::Plugin::CheckStrictVersion", "name" : "@DROLSKY/CheckStrictVersion", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::CheckSelfDependency", "config" : { "Dist::Zilla::Plugin::CheckSelfDependency" : { "finder" : [ ":InstallModules" ] }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000033", "version" : "0.004" } }, "name" : "@DROLSKY/CheckSelfDependency", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@DROLSKY/CheckPrereqsIndexed", "version" : "0.020" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch", "config" : { "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." } }, "name" : "@DROLSKY/DROLSKY::Git::CheckFor::CorrectBranch", "version" : "0.85" }, { "class" : "Dist::Zilla::Plugin::EnsureChangesHasContent", "name" : "@DROLSKY/EnsureChangesHasContent", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts", "config" : { "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." } }, "name" : "@DROLSKY/Git::CheckFor::MergeConflicts", "version" : "0.014" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::TidyAll", "name" : "@DROLSKY/DROLSKY::TidyAll", "version" : "0.85" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "CONTRIBUTING.md", "Changes", "LICENSE", "Makefile.PL", "README.md", "cpanfile", "tidyall.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." } }, "name" : "@DROLSKY/Git::Check", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%v%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "CONTRIBUTING.md", "Changes", "LICENSE", "Makefile.PL", "README.md", "cpanfile", "tidyall.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/Commit generated files", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "v0.56", "tag_format" : "v%v", "tag_message" : "v%v" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/Git::Tag", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." } }, "name" : "@DROLSKY/Git::Push", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "munge_makefile_pl" : 1 } }, "name" : "@DROLSKY/BumpVersionAfterRelease", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "Bump version after release" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [ "(?^:.+)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/Commit version bump", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.7.4", "repo_root" : "." } }, "name" : "@DROLSKY/Push version bump", "version" : "2.042" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "DevelopRequires", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::DynamicPrereqs", "config" : { "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000033", "version" : "0.004" } }, "name" : "DynamicPrereqs", "version" : "0.033" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.010" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.010" } }, "x_authority" : "cpan:DROLSKY", "x_contributors" : [ "Aaron Crane ", "BackPan ", "Brad Forschinger ", "David Golden ", "jddurand ", "Jens Rehsack ", "J.R. Mash ", "Karen Etheridge ", "Ricardo Signes ", "Toby Inkster ", "Tokuhiro Matsuno ", "Tom Wyant " ], "x_serialization_backend" : "Cpanel::JSON::XS version 3.0233" } List-SomeUtils-0.56/lib/0000775000175000017500000000000013134705504014713 5ustar autarchautarchList-SomeUtils-0.56/lib/List/0000775000175000017500000000000013134705504015626 5ustar autarchautarchList-SomeUtils-0.56/lib/List/SomeUtils/0000775000175000017500000000000013134705504017552 5ustar autarchautarchList-SomeUtils-0.56/lib/List/SomeUtils/PP.pm0000644000175000017500000002523713134705504020436 0ustar autarchautarchpackage List::SomeUtils::PP; use 5.006; use strict; use warnings; use List::Util qw( max ); our $VERSION = '0.56'; sub any (&@) { my $f = shift; foreach (@_) { return 1 if $f->(); } return 0; } sub all (&@) { my $f = shift; foreach (@_) { return 0 unless $f->(); } return 1; } sub none (&@) { my $f = shift; foreach (@_) { return 0 if $f->(); } return 1; } sub notall (&@) { my $f = shift; foreach (@_) { return 1 unless $f->(); } return 0; } sub one (&@) { my $f = shift; my $found = 0; foreach (@_) { $f->() and $found++ and return 0; } $found; } sub any_u (&@) { my $f = shift; return if !@_; $f->() and return 1 foreach (@_); return 0; } sub all_u (&@) { my $f = shift; return if !@_; $f->() or return 0 foreach (@_); return 1; } sub none_u (&@) { my $f = shift; return if !@_; $f->() and return 0 foreach (@_); return 1; } sub notall_u (&@) { my $f = shift; return if !@_; $f->() or return 1 foreach (@_); return 0; } sub one_u (&@) { my $f = shift; return if !@_; my $found = 0; foreach (@_) { $f->() and $found++ and return 0; } $found; } sub true (&@) { my $f = shift; my $count = 0; $f->() and ++$count foreach (@_); return $count; } sub false (&@) { my $f = shift; my $count = 0; $f->() or ++$count foreach (@_); return $count; } sub firstidx (&@) { my $f = shift; foreach my $i ( 0 .. $#_ ) { local *_ = \$_[$i]; return $i if $f->(); } return -1; } sub firstval (&@) { my $test = shift; foreach (@_) { return $_ if $test->(); } return undef; } sub firstres (&@) { my $test = shift; foreach (@_) { my $testval = $test->(); $testval and return $testval; } return undef; } sub onlyidx (&@) { my $f = shift; my $found; foreach my $i ( 0 .. $#_ ) { local *_ = \$_[$i]; $f->() or next; defined $found and return -1; $found = $i; } return defined $found ? $found : -1; } sub onlyval (&@) { my $test = shift; my $result = undef; my $found = 0; foreach (@_) { $test->() or next; $result = $_; $found++ and return undef; } return $result; } sub onlyres (&@) { my $test = shift; my $result = undef; my $found = 0; foreach (@_) { my $rv = $test->() or next; $result = $rv; $found++ and return undef; } return $found ? $result : undef; } sub lastidx (&@) { my $f = shift; foreach my $i ( reverse 0 .. $#_ ) { local *_ = \$_[$i]; return $i if $f->(); } return -1; } sub lastval (&@) { my $test = shift; my $ix; for ( $ix = $#_; $ix >= 0; $ix-- ) { local *_ = \$_[$ix]; my $testval = $test->(); # Simulate $_ as alias $_[$ix] = $_; return $_ if $testval; } return undef; } sub lastres (&@) { my $test = shift; my $ix; for ( $ix = $#_; $ix >= 0; $ix-- ) { local *_ = \$_[$ix]; my $testval = $test->(); # Simulate $_ as alias $_[$ix] = $_; return $testval if $testval; } return undef; } sub insert_after (&$\@) { my ( $f, $val, $list ) = @_; my $c = &firstidx( $f, @$list ); @$list = ( @{$list}[ 0 .. $c ], $val, @{$list}[ $c + 1 .. $#$list ], ) and return 1 if $c != -1; return 0; } sub insert_after_string ($$\@) { my ( $string, $val, $list ) = @_; my $c = firstidx { defined $_ and $string eq $_ } @$list; @$list = ( @{$list}[ 0 .. $c ], $val, @{$list}[ $c + 1 .. $#$list ], ) and return 1 if $c != -1; return 0; } sub apply (&@) { my $action = shift; &$action foreach my @values = @_; wantarray ? @values : $values[-1]; } sub after (&@) { my $test = shift; my $started; my $lag; grep $started ||= do { my $x = $lag; $lag = $test->(); $x; }, @_; } sub after_incl (&@) { my $test = shift; my $started; grep $started ||= $test->(), @_; } sub before (&@) { my $test = shift; my $more = 1; grep $more &&= !$test->(), @_; } sub before_incl (&@) { my $test = shift; my $more = 1; my $lag = 1; grep $more &&= do { my $x = $lag; $lag = !$test->(); $x; }, @_; } sub indexes (&@) { my $test = shift; grep { local *_ = \$_[$_]; $test->() } 0 .. $#_; } sub pairwise (&\@\@) { my $op = shift; # Symbols for caller's input arrays use vars qw{ @A @B }; local ( *A, *B ) = @_; # Localise $a, $b my ( $caller_a, $caller_b ) = do { my $pkg = caller(); no strict 'refs'; \*{ $pkg . '::a' }, \*{ $pkg . '::b' }; }; # Loop iteration limit my $limit = $#A > $#B ? $#A : $#B; # This map expression is also the return value local ( *$caller_a, *$caller_b ); map { # Assign to $a, $b as refs to caller's array elements ( *$caller_a, *$caller_b ) = \( $A[$_], $B[$_] ); # Perform the transformation $op->(); } 0 .. $limit; } sub each_array (\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) { return each_arrayref(@_); } sub each_arrayref { my @list = @_; # The list of references to the arrays my $index = 0; # Which one the caller will get next my $max = 0; # Number of elements in longest array # Get the length of the longest input array foreach (@list) { unless ( ref $_ eq 'ARRAY' ) { require Carp; Carp::croak("each_arrayref: argument is not an array reference\n"); } $max = @$_ if @$_ > $max; } # Return the iterator as a closure wrt the above variables. return sub { if (@_) { my $method = shift; unless ( $method eq 'index' ) { require Carp; Carp::croak("each_array: unknown argument '$method' passed to iterator."); } # Return current (last fetched) index return undef if $index == 0 || $index > $max; return $index - 1; } # No more elements to return return if $index >= $max; my $i = $index++; # Return ith elements return map $_->[$i], @list; } } sub natatime ($@) { my $n = shift; my @list = @_; return sub { return splice @list, 0, $n; } } sub mesh (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) { my $max = -1; $max < $#$_ && ( $max = $#$_ ) foreach @_; map { my $ix = $_; map $_->[$ix], @_; } 0 .. $max; } sub uniq (@) { my %seen = (); my $k; my $seen_undef; grep { defined $_ ? not $seen{ $k = $_ }++ : not $seen_undef++ } @_; } sub singleton (@) { my %seen = (); my $k; my $seen_undef; grep { 1 == ( defined $_ ? $seen{ $k = $_ } : $seen_undef ) } grep { defined $_ ? not $seen{ $k = $_ }++ : not $seen_undef++ } @_; } sub minmax (@) { return unless @_; my $min = my $max = $_[0]; for ( my $i = 1; $i < @_; $i += 2 ) { if ( $_[ $i - 1 ] <= $_[$i] ) { $min = $_[ $i - 1 ] if $min > $_[ $i - 1 ]; $max = $_[$i] if $max < $_[$i]; } else { $min = $_[$i] if $min > $_[$i]; $max = $_[ $i - 1 ] if $max < $_[ $i - 1 ]; } } if ( @_ & 1 ) { my $i = $#_; if ( $_[ $i - 1 ] <= $_[$i] ) { $min = $_[ $i - 1 ] if $min > $_[ $i - 1 ]; $max = $_[$i] if $max < $_[$i]; } else { $min = $_[$i] if $min > $_[$i]; $max = $_[ $i - 1 ] if $max < $_[ $i - 1 ]; } } return ( $min, $max ); } sub part (&@) { my ( $code, @list ) = @_; my @parts; push @{ $parts[ $code->($_) ] }, $_ foreach @list; return @parts; } sub bsearch(&@) { my $code = shift; my $rc; my $i = 0; my $j = @_; do { my $k = int( ( $i + $j ) / 2 ); $k >= @_ and return; local *_ = \$_[$k]; $rc = $code->(); $rc == 0 and return wantarray ? $_ : 1; if ( $rc < 0 ) { $i = $k + 1; } else { $j = $k - 1; } } until $i > $j; return; } sub bsearchidx(&@) { my $code = shift; my $rc; my $i = 0; my $j = @_; do { my $k = int( ( $i + $j ) / 2 ); $k >= @_ and return -1; local *_ = \$_[$k]; $rc = $code->(); $rc == 0 and return $k; if ( $rc < 0 ) { $i = $k + 1; } else { $j = $k - 1; } } until $i > $j; return -1; } sub sort_by(&@) { my ( $code, @list ) = @_; return map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, scalar( $code->() ) ] } @list; } sub nsort_by(&@) { my ( $code, @list ) = @_; return map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, scalar( $code->() ) ] } @list; } sub mode (@) { my %v; $v{$_}++ for @_; my $max = max( values %v ); return grep { $v{$_} == $max } keys %v; } 1; # ABSTRACT: Pure Perl implementation for List::SomeUtils __END__ =pod =encoding UTF-8 =head1 NAME List::SomeUtils::PP - Pure Perl implementation for List::SomeUtils =head1 VERSION version 0.56 =head1 DESCRIPTION There are no user-facing parts here. See L for API details. =head1 HISTORICAL COPYRIGHT Some parts copyright 2011 Aaron Crane. Copyright 2004 - 2010 by Tassilo von Parseval Copyright 2013 - 2015 by Jens Rehsack =head1 SUPPORT Bugs may be submitted at L. I am also usually active on IRC as 'autarch' on C. =head1 SOURCE The source code repository for List-SomeUtils can be found at L. =head1 AUTHORS =over 4 =item * Tassilo von Parseval =item * Adam Kennedy =item * Jens Rehsack =item * Dave Rolsky =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Dave Rolsky . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of the license can be found in the F file included with this distribution. =cut List-SomeUtils-0.56/lib/List/SomeUtils.pm0000644000175000017500000006432613134705504020121 0ustar autarchautarchpackage List::SomeUtils; use 5.006; use strict; use warnings; our $VERSION = '0.56'; use Exporter qw( import ); use Module::Implementation; my @subs = qw( after after_incl all all_u any any_u apply before before_incl bsearch bsearchidx each_array each_arrayref false firstidx firstres firstval indexes insert_after insert_after_string lastidx lastres lastval mesh minmax mode natatime none none_u notall notall_u nsort_by one one_u onlyidx onlyres onlyval pairwise part singleton sort_by true uniq ); my %aliases = ( bsearch_index => 'bsearchidx', distinct => 'uniq', first_index => 'firstidx', first_result => 'firstres', first_value => 'firstval', last_index => 'lastidx', last_result => 'lastres', last_value => 'lastval', only_index => 'onlyidx', only_result => 'onlyres', only_value => 'onlyval', zip => 'mesh', ); our @EXPORT_OK = ( @subs, keys %aliases ); our %EXPORT_TAGS = ( all => \@EXPORT_OK ); { my $loader = Module::Implementation::build_loader_sub( implementations => [ 'XS', 'PP' ], symbols => \@subs, ); $loader->(); } for my $alias ( keys %aliases ) { ## no critic (TestingAndDebugging::ProhibitNoStrict) no strict 'refs'; *{$alias} = __PACKAGE__->can( $aliases{$alias} ); } ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) sub _XScompiled { return Module::Implementation::implementation_for(__PACKAGE__) eq 'XS'; } 1; # ABSTRACT: Provide the stuff missing in List::Util __END__ =pod =encoding UTF-8 =head1 NAME List::SomeUtils - Provide the stuff missing in List::Util =head1 VERSION version 0.56 =head1 SYNOPSIS # import specific functions use List::SomeUtils qw( any uniq ); if ( any {/foo/} uniq @has_duplicates ) { # do stuff } # import everything use List::SomeUtils ':all'; =head1 DESCRIPTION B provides some trivial but commonly needed functionality on lists which is not going to go into L. All of the below functions are implementable in only a couple of lines of Perl code. Using the functions from this module however should give slightly better performance as everything is implemented in C. The pure-Perl implementation of these functions only serves as a fallback in case the C portions of this module couldn't be compiled on this machine. =head1 WHY DOES THIS MODULE EXIST? You might wonder why this module exists when we already have L. In fact, this module is (nearly) the same code as is found in LMU with no significant changes. However, the LMU distribution depends on several modules for configuration (to run the Makefile.PL) that some folks in the Perl community don't think are appropriate for a module high upstream in the CPAN river. I (Dave Rolsky) don't have a strong opinion on this, but I I like the functions provided by LMU, and I'm tired of getting patches and PRs to remove LMU from my code. This distribution exists to let me use the functionality I like without having to get into tiring arguments about issues I don't really care about. =head1 EXPORTS =head2 Default behavior Nothing by default. To import all of this module's symbols use the C<:all> tag. Otherwise functions can be imported by name as usual: use List::SomeUtils ':all'; use List::SomeUtils qw{ any firstidx }; Because historical changes to the API might make upgrading List::SomeUtils difficult for some projects, the legacy API is available via special import tags. =head1 FUNCTIONS =head2 Junctions =head3 I There are two schools of thought for how to evaluate a junction on an empty list: =over =item * Reduction to an identity (boolean) =item * Result is undefined (three-valued) =back In the first case, the result of the junction applied to the empty list is determined by a mathematical reduction to an identity depending on whether the underlying comparison is "or" or "and". Conceptually: "any are true" "all are true" -------------- -------------- 2 elements: A || B || 0 A && B && 1 1 element: A || 0 A && 1 0 elements: 0 1 In the second case, three-value logic is desired, in which a junction applied to an empty list returns C rather than true or false Junctions with a C<_u> suffix implement three-valued logic. Those without are boolean. =head3 all BLOCK LIST =head3 all_u BLOCK LIST Returns a true value if all items in LIST meet the criterion given through BLOCK. Sets C<$_> for each item in LIST in turn: print "All values are non-negative" if all { $_ >= 0 } ($x, $y, $z); For an empty LIST, C returns true (i.e. no values failed the condition) and C returns C. Thus, C<< all_u(@list) >> is equivalent to C<< @list ? all(@list) : undef >>. B: because Perl treats C as false, you must check the return value of C with C or you will get the opposite result of what you expect. =head3 any BLOCK LIST =head3 any_u BLOCK LIST Returns a true value if any item in LIST meets the criterion given through BLOCK. Sets C<$_> for each item in LIST in turn: print "At least one non-negative value" if any { $_ >= 0 } ($x, $y, $z); For an empty LIST, C returns false and C returns C. Thus, C<< any_u(@list) >> is equivalent to C<< @list ? any(@list) : undef >>. =head3 none BLOCK LIST =head3 none_u BLOCK LIST Logically the negation of C. Returns a true value if no item in LIST meets the criterion given through BLOCK. Sets C<$_> for each item in LIST in turn: print "No non-negative values" if none { $_ >= 0 } ($x, $y, $z); For an empty LIST, C returns true (i.e. no values failed the condition) and C returns C. Thus, C<< none_u(@list) >> is equivalent to C<< @list ? none(@list) : undef >>. B: because Perl treats C as false, you must check the return value of C with C or you will get the opposite result of what you expect. =head3 notall BLOCK LIST =head3 notall_u BLOCK LIST Logically the negation of C. Returns a true value if not all items in LIST meet the criterion given through BLOCK. Sets C<$_> for each item in LIST in turn: print "Not all values are non-negative" if notall { $_ >= 0 } ($x, $y, $z); For an empty LIST, C returns false and C returns C. Thus, C<< notall_u(@list) >> is equivalent to C<< @list ? notall(@list) : undef >>. =head3 one BLOCK LIST =head3 one_u BLOCK LIST Returns a true value if precisely one item in LIST meets the criterion given through BLOCK. Sets C<$_> for each item in LIST in turn: print "Precisely one value defined" if one { defined($_) } @list; Returns false otherwise. For an empty LIST, C returns false and C returns C. The expression C is almost equivalent to C<1 == true BLOCK LIST>, except for short-cutting. Evaluation of BLOCK will immediately stop at the second true value. =head2 Transformation =head3 apply BLOCK LIST Applies BLOCK to each item in LIST and returns a list of the values after BLOCK has been applied. In scalar context, the last element is returned. This function is similar to C but will not modify the elements of the input list: my @list = (1 .. 4); my @mult = apply { $_ *= 2 } @list; print "\@list = @list\n"; print "\@mult = @mult\n"; __END__ @list = 1 2 3 4 @mult = 2 4 6 8 Think of it as syntactic sugar for for (my @mult = @list) { $_ *= 2 } =head3 insert_after BLOCK VALUE LIST Inserts VALUE after the first item in LIST for which the criterion in BLOCK is true. Sets C<$_> for each item in LIST in turn. my @list = qw/This is a list/; insert_after { $_ eq "a" } "longer" => @list; print "@list"; __END__ This is a longer list =head3 insert_after_string STRING VALUE LIST Inserts VALUE after the first item in LIST which is equal to STRING. my @list = qw/This is a list/; insert_after_string "a", "longer" => @list; print "@list"; __END__ This is a longer list =head3 pairwise BLOCK ARRAY1 ARRAY2 Evaluates BLOCK for each pair of elements in ARRAY1 and ARRAY2 and returns a new list consisting of BLOCK's return values. The two elements are set to C<$a> and C<$b>. Note that those two are aliases to the original value so changing them will modify the input arrays. @a = (1 .. 5); @b = (11 .. 15); @x = pairwise { $a + $b } @a, @b; # returns 12, 14, 16, 18, 20 # mesh with pairwise @a = qw/a b c/; @b = qw/1 2 3/; @x = pairwise { ($a, $b) } @a, @b; # returns a, 1, b, 2, c, 3 =head3 mesh ARRAY1 ARRAY2 [ ARRAY3 ... ] =head3 zip ARRAY1 ARRAY2 [ ARRAY3 ... ] Returns a list consisting of the first elements of each array, then the second, then the third, etc, until all arrays are exhausted. Examples: @x = qw/a b c d/; @y = qw/1 2 3 4/; @z = mesh @x, @y; # returns a, 1, b, 2, c, 3, d, 4 @a = ('x'); @b = ('1', '2'); @c = qw/zip zap zot/; @d = mesh @a, @b, @c; # x, 1, zip, undef, 2, zap, undef, undef, zot C is an alias for C. =head3 uniq LIST =head3 distinct LIST Returns a new list by stripping duplicate values in LIST by comparing the values as hash keys, except that undef is considered separate from ''. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 # returns "Mike", "Michael", "Richard", "Rick" my @n = distinct "Mike", "Michael", "Richard", "Rick", "Michael", "Rick" # returns '', undef, 'S1', A5' my @s = distinct '', undef, 'S1', 'A5' # returns '', undef, 'S1', A5' my @w = uniq undef, '', 'S1', 'A5' C is an alias for C. B can be used to give feedback about this behavior. =head3 singleton Returns a new list by stripping values in LIST occurring more than once by comparing the values as hash keys, except that undef is considered separate from ''. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of elements occurring only once in LIST. my @x = singleton 1,1,2,2,3,4,5 # returns 3 4 5 =head2 Partitioning =head3 after BLOCK LIST Returns a list of the values of LIST after (and not including) the point where BLOCK returns a true value. Sets C<$_> for each element in LIST in turn. @x = after { $_ % 5 == 0 } (1..9); # returns 6, 7, 8, 9 =head3 after_incl BLOCK LIST Same as C but also includes the element for which BLOCK is true. =head3 before BLOCK LIST Returns a list of values of LIST up to (and not including) the point where BLOCK returns a true value. Sets C<$_> for each element in LIST in turn. =head3 before_incl BLOCK LIST Same as C but also includes the element for which BLOCK is true. =head3 part BLOCK LIST Partitions LIST based on the return value of BLOCK which denotes into which partition the current value is put. Returns a list of the partitions thusly created. Each partition created is a reference to an array. my $i = 0; my @part = part { $i++ % 2 } 1 .. 8; # returns [1, 3, 5, 7], [2, 4, 6, 8] You can have a sparse list of partitions as well where non-set partitions will be undef: my @part = part { 2 } 1 .. 10; # returns undef, undef, [ 1 .. 10 ] Be careful with negative values, though: my @part = part { -1 } 1 .. 10; __END__ Modification of non-creatable array value attempted, subscript -1 ... Negative values are only ok when they refer to a partition previously created: my @idx = ( 0, 1, -1 ); my $i = 0; my @part = part { $idx[$++ % 3] } 1 .. 8; # [1, 4, 7], [2, 3, 5, 6, 8] =head2 Iteration =head3 each_array ARRAY1 ARRAY2 ... Creates an array iterator to return the elements of the list of arrays ARRAY1, ARRAY2 throughout ARRAYn in turn. That is, the first time it is called, it returns the first element of each array. The next time, it returns the second elements. And so on, until all elements are exhausted. This is useful for looping over more than one array at once: my $ea = each_array(@a, @b, @c); while ( my ($a, $b, $c) = $ea->() ) { .... } The iterator returns the empty list when it reached the end of all arrays. If the iterator is passed an argument of 'C', then it returns the index of the last fetched set of values, as a scalar. =head3 each_arrayref LIST Like each_array, but the arguments are references to arrays, not the plain arrays. =head3 natatime EXPR, LIST Creates an array iterator, for looping over an array in chunks of C<$n> items at a time. (n at a time, get it?). An example is probably a better explanation than I could give in words. Example: my @x = ('a' .. 'g'); my $it = natatime 3, @x; while (my @vals = $it->()) { print "@vals\n"; } This prints a b c d e f g =head2 Searching =head3 bsearch BLOCK LIST Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (stored in C<$_>) is smaller, a positive value if it is bigger and zero if it matches. Returns a boolean value in scalar context. In list context, it returns the element if it was found, otherwise the empty list. =head3 bsearchidx BLOCK LIST =head3 bsearch_index BLOCK LIST Performs a binary search on LIST which must be a sorted list of values. BLOCK must return a negative value if the current element (stored in C<$_>) is smaller, a positive value if it is bigger and zero if it matches. Returns the index of found element, otherwise C<-1>. C is an alias for C. =head3 firstval BLOCK LIST =head3 first_value BLOCK LIST Returns the first element in LIST for which BLOCK evaluates to true. Each element of LIST is set to C<$_> in turn. Returns C if no such element has been found. C is an alias for C. =head3 onlyval BLOCK LIST =head3 only_value BLOCK LIST Returns the only element in LIST for which BLOCK evaluates to true. Sets C<$_> for each item in LIST in turn. Returns C if no such element has been found. C is an alias for C. =head3 lastval BLOCK LIST =head3 last_value BLOCK LIST Returns the last value in LIST for which BLOCK evaluates to true. Each element of LIST is set to C<$_> in turn. Returns C if no such element has been found. C is an alias for C. =head3 firstres BLOCK LIST =head3 first_result BLOCK LIST Returns the result of BLOCK for the first element in LIST for which BLOCK evaluates to true. Each element of LIST is set to C<$_> in turn. Returns C if no such element has been found. C is an alias for C. =head3 onlyres BLOCK LIST =head3 only_result BLOCK LIST Returns the result of BLOCK for the first element in LIST for which BLOCK evaluates to true. Sets C<$_> for each item in LIST in turn. Returns C if no such element has been found. C is an alias for C. =head3 lastres BLOCK LIST =head3 last_result BLOCK LIST Returns the result of BLOCK for the last element in LIST for which BLOCK evaluates to true. Each element of LIST is set to C<$_> in turn. Returns C if no such element has been found. C is an alias for C. =head3 indexes BLOCK LIST Evaluates BLOCK for each element in LIST (assigned to C<$_>) and returns a list of the indices of those elements for which BLOCK returned a true value. This is just like C only that it returns indices instead of values: @x = indexes { $_ % 2 == 0 } (1..10); # returns 1, 3, 5, 7, 9 =head3 firstidx BLOCK LIST =head3 first_index BLOCK LIST Returns the index of the first element in LIST for which the criterion in BLOCK is true. Sets C<$_> for each item in LIST in turn: my @list = (1, 4, 3, 2, 4, 6); printf "item with index %i in list is 4", firstidx { $_ == 4 } @list; __END__ item with index 1 in list is 4 Returns C<-1> if no such item could be found. C is an alias for C. =head3 onlyidx BLOCK LIST =head3 only_index BLOCK LIST Returns the index of the only element in LIST for which the criterion in BLOCK is true. Sets C<$_> for each item in LIST in turn: my @list = (1, 3, 4, 3, 2, 4); printf "uniqe index of item 2 in list is %i", onlyidx { $_ == 2 } @list; __END__ unique index of item 2 in list is 4 Returns C<-1> if either no such item or more than one of these has been found. C is an alias for C. =head3 lastidx BLOCK LIST =head3 last_index BLOCK LIST Returns the index of the last element in LIST for which the criterion in BLOCK is true. Sets C<$_> for each item in LIST in turn: my @list = (1, 4, 3, 2, 4, 6); printf "item with index %i in list is 4", lastidx { $_ == 4 } @list; __END__ item with index 4 in list is 4 Returns C<-1> if no such item could be found. C is an alias for C. =head2 Sorting =head3 sort_by BLOCK LIST Returns the list of values sorted according to the string values returned by the KEYFUNC block or function. A typical use of this may be to sort objects according to the string value of some accessor, such as sort_by { $_->name } @people The key function is called in scalar context, being passed each value in turn as both $_ and the only argument in the parameters, @_. The values are then sorted according to string comparisons on the values returned. This is equivalent to sort { $a->name cmp $b->name } @people except that it guarantees the name accessor will be executed only once per value. One interesting use-case is to sort strings which may have numbers embedded in them "naturally", rather than lexically. sort_by { s/(\d+)/sprintf "%09d", $1/eg; $_ } @strings This sorts strings by generating sort keys which zero-pad the embedded numbers to some level (9 digits in this case), helping to ensure the lexical sort puts them in the correct order. =head3 nsort_by BLOCK LIST Similar to sort_by but compares its key values numerically. =head2 Counting and calculation =head3 true BLOCK LIST Counts the number of elements in LIST for which the criterion in BLOCK is true. Sets C<$_> for each item in LIST in turn: printf "%i item(s) are defined", true { defined($_) } @list; =head3 false BLOCK LIST Counts the number of elements in LIST for which the criterion in BLOCK is false. Sets C<$_> for each item in LIST in turn: printf "%i item(s) are not defined", false { defined($_) } @list; =head3 minmax LIST Calculates the minimum and maximum of LIST and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if LIST was empty. The C algorithm differs from a naive iteration over the list where each element is compared to two values being the so far calculated min and max value in that it only requires 3n/2 - 2 comparisons. Thus it is the most efficient possible algorithm. However, the Perl implementation of it has some overhead simply due to the fact that there are more lines of Perl code involved. Therefore, LIST needs to be fairly big in order for C to win over a naive implementation. This limitation does not apply to the XS version. =head3 mode LIST Calculates the most common items in the list and returns them as a list. This is effectively done by string comparisons, so references will be stringified. If they implement string overloading, this will be used. If more than one item appears the same number of times in the list, all such items will be returned. For example, the mode of a unique list is the list itself. This function B returns a list. That means that in scalar context you get a count indicating the number of modes in the list. =head1 MAINTENANCE The maintenance goal is to preserve the documented semantics of the API; bug fixes that bring actual behavior in line with semantics are allowed. New API functions may be added over time. If a backwards incompatible change is unavoidable, we will attempt to provide support for the legacy API using the same export tag mechanism currently in place. This module attempts to use few non-core dependencies. Non-core configuration and testing modules will be bundled when reasonable; run-time dependencies will be added only if they deliver substantial benefit. =head1 KNOWN ISSUES There is a problem with a bug in 5.6.x perls. It is a syntax error to write things like: my @x = apply { s/foo/bar/ } qw{ foo bar baz }; It has to be written as either my @x = apply { s/foo/bar/ } 'foo', 'bar', 'baz'; or my @x = apply { s/foo/bar/ } my @dummy = qw/foo bar baz/; Perl 5.5.x and Perl 5.8.x don't suffer from this limitation. If you have a functionality that you could imagine being in this module, please drop me a line. This module's policy will be less strict than L's when it comes to additions as it isn't a core module. When you report bugs, it would be nice if you could additionally give me the output of your program with the environment variable C set to a true value. That way I know where to look for the problem (in XS, pure-Perl or possibly both). =head1 THANKS =head2 Tassilo von Parseval Credits go to a number of people: Steve Purkis for giving me namespace advice and James Keenan and Terrence Branno for their effort of keeping the CPAN tidier by making L obsolete. Brian McCauley suggested the inclusion of apply() and provided the pure-Perl implementation for it. Eric J. Roode asked me to add all functions from his module C into this one. With minor modifications, the pure-Perl implementations of those are by him. The bunch of people who almost immediately pointed out the many problems with the glitchy 0.07 release (Slaven Rezic, Ron Savage, CPAN testers). A particularly nasty memory leak was spotted by Thomas A. Lowery. Lars Thegler made me aware of problems with older Perl versions. Anno Siegel de-orphaned each_arrayref(). David Filmer made me aware of a problem in each_arrayref that could ultimately lead to a segfault. Ricardo Signes suggested the inclusion of part() and provided the Perl-implementation. Robin Huston kindly fixed a bug in perl's MULTICALL API to make the XS-implementation of part() work. =head2 Jens Rehsack Credits goes to all people contributing feedback during the v0.400 development releases. Special thanks goes to David Golden who spent a lot of effort to develop a design to support current state of CPAN as well as ancient software somewhere in the dark. He also contributed a lot of patches to refactor the API frontend to welcome any user of List::SomeUtils - from ancient past to recently last used. Toby Inkster provided a lot of useful feedback for sane importer code and was a nice sounding board for API discussions. Peter Rabbitson provided a sane git repository setup containing entire package history. =head1 TODO A pile of requests from other people is still pending further processing in my mailbox. This includes: =over 4 =item * List::Util export pass-through Allow B to pass-through the regular L functions to end users only need to C the one module. =item * uniq_by(&@) Use code-reference to extract a key based on which the uniqueness is determined. Suggested by Aaron Crane. =item * delete_index =item * random_item =item * random_item_delete_index =item * list_diff_hash =item * list_diff_inboth =item * list_diff_infirst =item * list_diff_insecond These were all suggested by Dan Muey. =item * listify Always return a flat list when either a simple scalar value was passed or an array-reference. Suggested by Mark Summersault. =back =head1 SEE ALSO L, L, L =head1 HISTORICAL COPYRIGHT Some parts copyright 2011 Aaron Crane. Copyright 2004 - 2010 by Tassilo von Parseval Copyright 2013 - 2015 by Jens Rehsack =head1 SUPPORT Bugs may be submitted at L. I am also usually active on IRC as 'autarch' on C. =head1 SOURCE The source code repository for List-SomeUtils can be found at L. =head1 DONATIONS If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer. Please note that B in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me. Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together). To donate, log into PayPal and send money to autarch@urth.org, or use the button at L. =head1 AUTHORS =over 4 =item * Tassilo von Parseval =item * Adam Kennedy =item * Jens Rehsack =item * Dave Rolsky =back =head1 CONTRIBUTORS =for stopwords Aaron Crane BackPan Brad Forschinger David Golden jddurand Jens Rehsack J.R. Mash Karen Etheridge Ricardo Signes Toby Inkster Tokuhiro Matsuno Tom Wyant =over 4 =item * Aaron Crane =item * BackPan =item * Brad Forschinger =item * David Golden =item * jddurand =item * Jens Rehsack =item * J.R. Mash =item * Karen Etheridge =item * Ricardo Signes =item * Toby Inkster =item * Tokuhiro Matsuno =item * Tom Wyant =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017 by Dave Rolsky . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of the license can be found in the F file included with this distribution. =cut List-SomeUtils-0.56/perlcriticrc0000644000175000017500000000367113134705504016562 0ustar autarchautarchseverity = 3 verbose = 11 theme = core + pbp + bugs + maintenance + cosmetic + complexity + security + tests + moose program-extensions = pl psgi t exclude = Subroutines::ProhibitCallsToUndeclaredSubs [BuiltinFunctions::ProhibitStringySplit] severity = 3 [CodeLayout::RequireTrailingCommas] severity = 3 [ControlStructures::ProhibitCStyleForLoops] severity = 3 [InputOutput::RequireCheckedSyscalls] functions = :builtins exclude_functions = sleep severity = 3 [RegularExpressions::ProhibitComplexRegexes] max_characters = 200 [RegularExpressions::ProhibitUnusualDelimiters] severity = 3 [Subroutines::ProhibitUnusedPrivateSubroutines] private_name_regex = _(?!build)\w+ [TestingAndDebugging::ProhibitNoWarnings] allow = redefine [ValuesAndExpressions::ProhibitEmptyQuotes] severity = 3 [ValuesAndExpressions::ProhibitInterpolationOfLiterals] severity = 3 [ValuesAndExpressions::RequireUpperCaseHeredocTerminator] severity = 3 [Variables::ProhibitPackageVars] add_packages = Carp Test::Builder [-Subroutines::RequireFinalReturn] # This incorrectly thinks signatures are prototypes. [-Subroutines::ProhibitSubroutinePrototypes] [-ErrorHandling::RequireCarping] # No need for /xsm everywhere [-RegularExpressions::RequireDotMatchAnything] [-RegularExpressions::RequireExtendedFormatting] [-RegularExpressions::RequireLineBoundaryMatching] # http://stackoverflow.com/questions/2275317/why-does-perlcritic-dislike-using-shift-to-populate-subroutine-variables [-Subroutines::RequireArgUnpacking] # "use v5.14" is more readable than "use 5.014" [-ValuesAndExpressions::ProhibitVersionStrings] # Explicitly returning undef is a _good_ thing in many cases, since it # prevents very common errors when using a sub in list context to construct a # hash and ending up with a missing value or key. [-Subroutines::ProhibitExplicitReturnUndef] # Sometimes I want to write "return unless $x > 4" [-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions] List-SomeUtils-0.56/Makefile.PL0000644000175000017500000000703413134705504016121 0ustar autarchautarch# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.010. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Provide the stuff missing in List::Util", "AUTHOR" => "Tassilo von Parseval , Adam Kennedy , Jens Rehsack , Dave Rolsky ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "Text::ParseWords" => 0 }, "DISTNAME" => "List-SomeUtils", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "List::SomeUtils", "PREREQ_PM" => { "Carp" => 0, "Exporter" => 0, "List::Util" => 0, "Module::Implementation" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Scalar::Util" => 0, "Storable" => 0, "Test::Builder::Module" => 0, "Test::LeakTrace" => 0, "Test::More" => "0.96", "Tie::Array" => 0, "base" => 0, "lib" => 0, "overload" => 0 }, "VERSION" => "0.56", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "List::Util" => 0, "Module::Implementation" => 0, "Scalar::Util" => 0, "Storable" => 0, "Test::Builder::Module" => 0, "Test::LeakTrace" => 0, "Test::More" => "0.96", "Tie::Array" => 0, "base" => 0, "lib" => 0, "overload" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 ); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.033 requires('List::SomeUtils::XS', '0.54') if !want_pp() and can_xs(); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.033 sub _add_prereq { my ($mm_key, $module, $version_or_range) = @_; $version_or_range ||= 0; warn "$module already exists in $mm_key (at version $WriteMakefileArgs{$mm_key}{$module}) -- need to do a sane metamerge!" if exists $WriteMakefileArgs{$mm_key}{$module} and $WriteMakefileArgs{$mm_key}{$module} ne '0' and $WriteMakefileArgs{$mm_key}{$module} ne $version_or_range; warn "$module already exists in FallbackPrereqs (at version $WriteMakefileArgs{$mm_key}{$module}) -- need to do a sane metamerge!" if exists $FallbackPrereqs{$module} and $FallbackPrereqs{$module} ne '0' and $FallbackPrereqs{$module} ne $version_or_range; $WriteMakefileArgs{$mm_key}{$module} = $FallbackPrereqs{$module} = $version_or_range; return; } use lib 'inc'; use ExtUtils::HasCompiler 0.014 'can_compile_loadable_object'; { my $can_xs; sub can_xs { return $can_xs if defined $can_xs; $can_xs = can_compile_loadable_object(quiet => 1) ? 1 : 0; } } sub parse_args { require ExtUtils::MakeMaker; require Text::ParseWords; ExtUtils::MakeMaker::parse_args( my $tmp = {}, Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''), @ARGV, ); return $tmp->{ARGS} || {}; } sub requires { goto &runtime_requires } sub runtime_requires { my ($module, $version_or_range) = @_; _add_prereq(PREREQ_PM => $module, $version_or_range); } { my $want_pp; sub want_pp { return $want_pp if defined $want_pp; $want_pp = parse_args()->{PUREPERL_ONLY} ? 1 : 0 } }