perl5i-v2.12.0000750000765000024 012155475024 13117 5ustar00schwernstaff000000000000perl5i-v2.12.0/.perlcriticrc000444000765000024 376312155475023 15757 0ustar00schwernstaff000000000000## ### Configure perlcritic display behavior. ### # Change the default message to show the policy name so we can shut it up if necessary verbose = %m [%p] at %f line %l, near '%r'\n # Force perlcritic to use color, even when run through a pager. color = 1 # Use a pager. pager = $PAGER ### ### Turn off policies. ### # Nuthin wrong with the expression form of map and grep. [-BuiltinFunctions::RequireBlockMap] [-BuiltinFunctions::RequireBlockGrep] # We realize that localizing a variable does not retain it's original value, # thanks. [-Variables::RequireInitializationForLocalVars] # I'd rather use a few unnecessary "" then forget to interpolate. [-ValuesAndExpressions::ProhibitInterpolationOfLiterals] # Inline POD is more worthwhile than the dubious optimization of putting it # after the __END__ block [-Documentation::RequirePodAtEnd] # No, we're not going to use English. [-Variables::ProhibitPunctuationVars] # That's just rediculous [-ControlStructures::ProhibitPostfixControls] [-ValuesAndExpressions::ProhibitEmptyQuotes] [-ValuesAndExpressions::ProhibitNoisyQuotes] # Test::Builder makes heavy use of local() [-Variables::ProhibitLocalVars] # Nuthin wrong with @$foo [-References::ProhibitDoubleSigils] # We're going to be doing this a lot [-Modules::ProhibitMultiplePackages] [-Modules::RequireFilenameMatchesPackage] ### ### Configure policies ### # Extend the ability to play with @_ to 3 line subroutines. [Subroutines::RequireArgUnpacking] short_subroutine_statements = 3 # No tabs ever [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 # 'no strict "refs"' is ok [TestingAndDebugging::ProhibitNoStrict] allow = refs ### ### New policies and options which are not released yet. ### # "no warnings" is fine as long as it's restricted to one or more categories [TestingAndDebugging::ProhibitNoWarnings] allow_with_category_restriction = 1 # Don't need /x on small regexes. [RegularExpressions::RequireExtendedFormatting] minimum_regex_length_to_complain_about = 12 perl5i-v2.12.0/.perltidyrc000444000765000024 130412155475023 15440 0ustar00schwernstaff000000000000--maximum-line-length=100 # we have widescreen now --indent-columns=4 --continuation-indentation=2 --no-opening-sub-brace-on-new-line --paren-tightness=1 --square-bracket-tightness=1 --brace-tightness=1 --no-space-for-semicolon --no-outdent-long-quotes --output-line-ending=unix --no-outdent-labels --no-blanks-before-comments --blanks-before-subs --blanks-before-blocks --maximum-consecutive-blank-lines=2 # Allow two blanks between subroutines --nospace-after-keyword="my local our and or eq ne if else elsif until unless while for foreach return switch case given when" --want-break-before="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" perl5i-v2.12.0/Build.PL000444000765000024 702212155475023 14555 0ustar00schwernstaff000000000000#!/usr/bin/perl -w use strict; # Include 'lib' so it sees our perl5i::VERSION when version checking use lib 'inc', 'lib'; use MyBuild; use 5.010; my $builder = MyBuild->new( module_name => 'perl5i', license => 'perl', dist_author => 'Michael G Schwern ', dist_version => "v2.12.0", requires => { 'perl' => '5.10.0', 'Modern::Perl' => '1.03', 'CLASS' => '1.00', 'Child' => '0.009', 'DateTime' => '0.47', 'DateTime::Format::Epoch' => '0.11', 'DateTime::TimeZone::Tzfile' => '0.002', 'Module::Load' => '0.16', # for perl5i::1 'Text::Wrap' => '2009.0305', 'Try::Tiny' => '0.02', 'autodie' => '2.12', # plays nice with open pragma 'IPC::System::Simple' => '1.18', # Needed for autodie :system 'autobox' => '2.70', 'autobox::Core' => '1.0', parent => '0.221', 'File::chdir' => '0.1002', 'autobox::dump' => '20090426', # for perl5i::1 'autobox::List::Util' => '20090629', 'Want' => '0.18', 'autovivification' => '0.06', 'version' => '0.77', 'Perl6::Caller' => '0.100', "Taint::Util" => '0.06', 'Hash::Merge::Simple' => '0.04', 'List::MoreUtils' => '0.22', indirect => '0.24', 'JSON' => '2.17', 'YAML::Any' => '0.70', 'Digest::SHA' => '5.45', 'Digest::MD5' => '2.36', 'Object::ID' => '0.1.0', "Devel::Declare::MethodInstaller::Simple" => '0.006009', 'true::VERSION' => '0.16', 'Capture::Tiny' => '0.06', 'utf8::all' => '0.002', 'Carp::Fix::1_25' => '1.000000', 'Hash::StoredIterator' => '0.005', 'Hash::FieldHash' => '0.06', }, build_requires => { 'ExtUtils::CBuilder' => '0.26', 'Test::More' => '0.88', 'Test::Warn' => '0.11', 'IPC::Open3' => '0', 'Test::Output' => '0.16', }, configure_requires => { # MB's auto configure requires only puts it in the META.yml # so some CPAN shells won't see it. "Module::Build" => '0.36', }, meta_merge => { resources => { repository => 'http://github.com/schwern/perl5i/tree/master', bugtracker => 'http://github.com/schwern/perl5i/issues', Chat => "irc://irc.perl.org/#perl5i", }, no_index => { file => [qw( lib/perl5i/0/DateTime.pm lib/perl5i/0/ARRAY.pm lib/perl5i/0/DEFAULT.pm lib/perl5i/0/HASH.pm lib/perl5i/0/Meta.pm lib/perl5i/0/Meta/Class.pm lib/perl5i/0/Meta/Instance.pm lib/perl5i/0/SCALAR.pm lib/perl5i/VERSION.pm )], }, }, PL_files => { 'bin/perl5i.c.PL' => 'bin/perl5i.c', 'bin/perl5i.bat.PL' => 'bin/perl5i.bat', }, recursive_test_files => 1, create_readme => 1, create_license => 1, ); $builder->requires->{"Time::y2038"} = "20100218" if $builder->needs_y2038; $builder->create_build_script(); perl5i-v2.12.0/Changes000444000765000024 4243212155475023 14600 0ustar00schwernstaff0000000000002.12.0 Mon Jun 10 18:09:31 PDT 2013 New Features * Added the ability to skip loading certain features. [github #228] (Michael G Schwern) (Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯) Bug Fixes * Quiet "smartmatch is experimental" warnings in 5.18. [github #261] (Chuck Adams) Doc Changes * Document ->mo->as_yaml and ->mo->as_json [github #230] (Michael G. Schwern) * Remove references to the defunct mailing list [github #235] (Michael G. Schwern) * Add references to the wiki and Twitter [github #235] (Michael G. Schwern) Test Fixes * Test fixes for 5.18. [github #264] [github #262] (Chuck Adams) (Michael G Schwern) Distribution Fixes * Require a newer, safer version of Devel::Declare. [github #181] (Michael G Schwern) (Ben Hengst) * Forgot to explicitly depend on Hash::FieldHash. (Michael G Schwern) * Upgrade Hash::StoredIterator to avoid 5.12, 5.14 and 5.18 failures. (Michael G Schwern) (Chad Granum) 2.11.2 Mon Mar 18 02:55:20 GMT 2013 Distribution Fixes * perl5i::0 and perl5i::1 had internal packages outside the perl5i package which caused CPAN permissions problems. This has been fixed. (Michael G. Schwern) 2.11.1 Mon Mar 18 02:32:07 UTC 2013 Distribution Fixes * Creating a new release with correct PAUSE permissions (Nóirín Plunkett) 2.11.0 Mon Mar 18 02:24:20 UTC 2013 Bug Fixes * %hash->each({...}) iterator now uses Hash::StoredIterator to ensure that it's safe to nest calls to each(), and to use keys() and values() inside each() (Chad Granum) Test Fixes * Added new test template (Michael G. Schwern) New Features * ->mo->as_yaml and ->mo->as_json now allow you to dump a meta-object as yaml or json respectively [github #230] (Ben Hengst) Misc * Fixed examples in the documentation (Tom Legrady) 2.10.0 Sat Jul 7 11:57:01 PDT 2012 Bug Fixes * Upgraded autodie dependency to fix automatic utf8 open. [github #220] [github #218] Test Fixes * Removed a use of Test::Exception, which we don't depend on. New Features * %hash = @array->as_hash; will turn all the values in @array to keys in %hash. [github 172] (Prashan Dharmasena) * @array->popn($n) and @array->shiftn() pop() and shift() multiple elements off an array. [github 149] (Tanner Hobson) * @array->pick($n) and @array->pick_one will pick random elements out of an @array, like picking cards from a deck. [github 145] (Prashan Dharmasena) * The Carp 1.25 formatting change has been smoothed over using Carp::Fix::1_25. 2.9.1 Fri Nov 11 16:13:32 PST 2011 Bug Fixes * @empty_array->foreach(\&callback) would do the callback() once despite the array being empty. [github 211] (Andrew Parker) 2.9.0 Sun Oct 23 00:47:24 PDT 2011 New Features * %hash->each() is guaranteed to iterate through the entire hash. [github 142] * $string->is_module_name() checks if a string is a valid module name. Doc Changes * Document the very useful %hash->each( func ($k, $v) { ... } ). [github 142] * Add perl5ifaq entry: "How do I merge two hashes?" * Add perl5ifaq entry: "How can I get the unique keys from multiple hashes?" * Minor POD glitches and spelling fixes from Debian. [rt.cpan.org 71253] [rt.cpan.org 71254] Test Fixes * Updated tests for new version of Child. (Chad Granum) Bug Fixes * Depend on the newest version of Child. (Chad Granum) Security Fixes * require() will now only require modules. [github #204] 2.8.0 Sat Sep 24 21:36:32 PDT 2011 Bug Fixes * Depend on a newer, more reliable version of Devel::Declare. Lets perl5i work with Devel::REPL. [github 153] * Depend on a newer indirect.pm to avoid leaks into eval on 5.10. [rt.cpan.org 64521] * Quiet the overzealous "v-string in use/require non-portable" warning from 5.10.0. [github 174] New Features * Added a list() keyword to force list context. Compliments scalar(). [github #169] (Mike Doherty) * `strict vars` is now off for perl5i one-liners. [github #63] (Mike Doherty) * alias() will no longer issue "subroutine redefined" warnings. There was no way to make them honor "no warnings 'redefine'". [github #185] (Mike Doherty) * -Mperl5i now means -Mperl5i::latest rather than spitting at you. [github #193] (Mike Doherty) * $string->reverse now always reverses $string regardless of context. [github #182] Doc Changes * Removed unnecessarily detailed docs about Child. Misc * Delegate Unicode stuff to utf8::all. [github #190] * checksum() now using the core Digest::SHA module instead of Digest::SHA1. [github #196] (Mike Doherty) 2.6.1 Thu, 24 Mar 2011 16:33:39 +1100 Bug Fixes * methods() can handle modules like Fcntl with weird things in their symbol tables. [github 184] Test Fixes * Work around broken Test::Output 0.16_03 alpha that CPAN testers are using. See https://rt.cpan.org/Ticket/Display.html?id=66172 2.6.0 Thu, 24 Feb 2011 11:23:25 +1100 New Features * Added capture(), from Capture::Tiny, to capture output to STDOUT and STDERR [github 178] New Docs * Added perl5ifaq entries for capturing output from a command using capture() Bug Fixes * perl5i will no longer double encode @ARGV if it's loaded multiple times. [github 176] Windows Fixes * Fix t/center.t (Myf White) * Fix t/command_line_wrapper.t (Myf White) Misc * The dependency on true.pm will no longer confuse some YAML parsers. 2.5.1 Fri, 28 Jan 2011 11:01:33 +1000 Misc * Fix the META.yml file so the requirement on "true" is not interpreted as a boolean by YAML::XS. [github 173] 2.5.0 Mon, 24 Jan 2011 11:03:38 +1000 Doc Fixes * Update the Artistic License link to one that works. (Schwern) New Features * Added $class->mc->symbol_table to get a class's symbol table (Schwern) * Added $obj->mo->methods to get the methods available to an object (Schwern) [github 170] 2.4.1 Wed Nov 24 16:35:39 EST 2010 Bug Fixes * The lexical nature of the improved error message was implemented wrong and caused it to leak out or not work. [github 99] (Schwern) 2.4.0 Fri Aug 27 19:18:45 PDT 2010 New Features * You no longer have to put a true value at the end of a module. Thanks to chocolateboy's true.pm! Bug Fixes * Bumped the dependency on indirect.pm to avoid a seg fault in @{[ $x->$y ]} when $x and $y are undefined. [github 164] Thanks to Tokuhiro Matsuno and Vincent Pit. * The improved error message for failing to load a module is now a lexical feature. This prevents it messing up things that parse that error message, like base.pm. This makes perl5i play nice with Class::DBI amongst a lot of other things. [github 165] (Chad) 2.3.1 Fri Jul 30 18:14:38 PDT 2010 No changes from 2.3.0_03. 2.3.0_03 Wed Jul 28 20:32:36 PDT 2010 Incompatible Changes (only with this alpha series) * Signature->num_params is now Signature->num_positional_params because we'll add named params eventually and you generally only care about how many positional params a function takes. (Schwern) * Remove ngrep, nmap and nfor. Replaced by @array->foreach( def($x,$y) ) {} and @array->map( def($x) {} ); * def has been removed. Consensus is emerging for func. New Features * Added child() to make forking easier. [github 150] (Chad) * @array->foreach now takes a function with variable arguments and DWIM * $number->is_even and is_odd [github 143] (Eric A. Zarko) Bug Fixes * Anonymous functions were getting a new signature each time they're declared even though its the same code reference. (Schwern) 2.3.0_02 Thu Jul 15 19:13:22 PDT 2010 New Features * Signature introspection, via $code->signature, for subroutines defined with C, C and C. Documentation * Anonymous methods and functions (they always worked) 2.3.0_01 Mon Jul 12 16:15:05 PDT 2010 New Features * ngrep and nmap are like grep and map but you can name the $_ variable. (Chad) [github 36] * nfor is like for but you can specify it to loop over any number of elements at a time. (Chad) [github 40] * "method" declares a method and does the "my $self = shift" for you. (Schwern) [github 19] * "def" and "func" provide basic subroutine signatures. (Schwern) [github 19] * The error message upon not being able to load a module has been improved for human readability. (Chad) [github 99] Test Fixes * Clean up dangling temp files. (Avar) [github 139] 2.2.2 Mon May 17 16:34:52 PDT 2010 Bug Fixes * Let perl5i::1 load without Time::y2038 if Perl is already y2038 safe just like perl5i::2 does. Test Fixes * Possible failure of t/command_line_wrapper.t if perl5i isn't already installed. 2.2.1 Sun May 16 22:52:01 PDT 2010 Bug Fixes * Greatly reduced the amount of clashes when loading perl5i::1 and perl5i::2. * Make meta objects on read only strings and numbers work with non-threaded perls. [github 131] * Bumped to a version of indirect which does not leak out of scope. [rt.cpan.org 50570] 2.2.0 Sun May 9 13:22:56 PDT 2010 New Features * $thing->mo->is_tainted, along with untaint and taint, are now callable on everything to provide a unified interface. [github 89] * Added $number->commify and $number->group_digits to turn 1000 into 1,000. [github 128] * Added $obj->mo->id, a universal unique object identifier. Deprecation Warnings * $thing->is_tainted, untaint and taint will be removed in v3. Please use $thing->mo->is_tainted and friends. [github 89] Bug Fixes * $class->can($method) now works as it should (previously autoboxing would interfere). [github 112] 2.1.1 Tue Apr 27 21:34:04 PDT 2010 Fixes * Upgrade dependency on autovivification so Regexp::Common works with perl5i. [github 32] 2.1.0 Fri Apr 16 12:15:10 EEST 2010 New Features * trim, ltrim and rtrim now work on arrays. [github 121] (Nick Patch) Fixes * Quiet a warning in DateTime.pm on systems where gmtime() returns undef for out of bound times (mostly Windows). * Fix the perl5i command line tool on stock OS X 5.10.0 [github 116] * Fix perl5i.bat on Windows. * perl5i can load after List::MoreUtils (and thus things like Moose) [github 127] * Fix is_integer() and is_decimal() for things like 1.0 and 1. [github 123] * Fix rounding of negative numbers. [github 118] Test Fixes * Quiet the autodie test on Windows [github 126] * Fix the quoting of command_line_wrapper.t for Windows [github 126] 2.0.3 Fri Mar 19 13:57:37 PDT 2010 Fixes * Forgot to require B before using a B routine in the JSON dump. Build Fixes * Forgot to require Digest::SHA1 for checksum() Test Fixes * Removed use of Test::Exception which may have been causing the "Bizarre copy of HASH" errors in 5.11.5. 2.0.2 Wed Mar 17 12:21:00 PDT 2010 Build Fixes * Ensure non META.yml savy CPAN shells see the configure_requires for Module::Build. * Forgot to require indirect.pm, JSON and YAML::Any Test Fixes * Don't run the v1 and v0 sanity tests unless Time::y2038 is installed. * autobox 2.60 changed how isa() works and broke 42->isa("UNIVERSAL"). Will fix for real later. 2.0.1 Wed Mar 17 11:10:54 PDT 2010 Fixes * Quick fix to handle not always having Time::y2038. 2.0.0 Tue Mar 16 23:34:22 PDT 2010 Incompatible Changes * In general, methods which return a list return an array in list context and an array ref in scalar context. This enables chaining of autoboxed methods. * $module->load() is now $module->require() with simpler semantics. [github 107] [schwern] * Indirect object syntax (ie. $obj = new Class) is now a compile time syntax error. * $thing->mo now always returns a meta instance object. This allows the meta object to DWIM on plain strings which previously would be treated as classes and return the meta class object. * The guaranteed range of gm/localtime() has been reduced to avoid depending on Time::y2038 if possible. * $thing->perl is now $thing->mo->perl and works on everything. New Features * $thing->mo->is_equal($other) universal equality method. [brunov] * $thing->mc has been added to always return a meta class object. This allows disambiguation when $thing could be considered a class name. * new autoboxed methods: %hash->diff() and %hash->intersect() [brunov] * Added $thing->mo->dump to dump objects in multiple formats including YAML and JSON. Fixes * Update dep on autovivification to one that works on 5.11 [schwern] * Update autobox::Core dep to clarify scalar vs list context returns. * Fix taint test failing with Test::More 0.95_01. [schwern] * Fix time compat test failing because of unknown time zones. [schwern] * Time::y2038 is only required if the built in time functions are not up to task. [schwern] Optimizations * Optimize @array->intersect() and @array->diff() when @array contains no refs. [brunov] 1.1.0 Tue Mar 2 19:09:49 PST 2010 New Features * print() and say() now work on hashes, time(), localtime() and gmtime(). * $obj->mo->checksum will return a checksum for the contents of any object. * Added $path->path2module and $module->module2path Bugs * alias() was still being exported. * Work around DateTime::TimeZone not being able to determine the local time zone on FreeBSD and possibly others. * localtime() is less suseptable to the DateTime distant year DOS attack. Docs * Document that carp() and croak() are exported. 1.0.0 Thu Feb 25 21:56:47 PST 2010 New Features * @array->first() now takes a regex like @array->grep() [github 93] (brunov) * All autoboxed objects now respond to is_number() and friends. They always return false. [github 100] (brunov) * All applicable array and hash methods now return arrays in list context and array refs in scalar context. (brunov) * diff() now works on nested data structures and honors overloaded objects (brunov) * Add a basic $number->round() [github 95] * Added @array->intersect() (brunov) Docs * Wrote perl5ifaq for all your frequently asked questions. * Document the perl5i command line utility. [github 31] Bug Fixes * Ensure the DateTime objects coming from time(), gmtime() and localtime() compare with eq and == 0.2.2 Fri Feb 19 14:56:36 PST 2010 Other * Some modules got the wrong version. 0.2.1 Fri Feb 19 04:23:58 PST 2010 Bug Fixes * round_up() and round_down() didn't work 0.2.0 Fri Feb 19 03:48:36 PST 2010 Incompatible Changes * "use perl5i" no longer works. You must instead "use perl5i::0" to protect against future incompatibilities. "use perl5i::latest" for the adventurous. * We no longer export rreturn() or lnoreturn() from Want. This can wait if we tackle lvalue subroutines. * load() is now a scalar method, so its $module->load not load($module) * alias() is now an autoboxed method rather than a function. New Features * try/catch support via Try::Tiny (brunov) * caller() now returns an object via Perl6::Caller (schwern, Timothy Totten) * Everything has a Meta object (perl5i::Meta) accessable via $thing->mo * Added meta object methods to handle tainting. mo->is_tainted(), mo->taint(), mo->untaint(). * Added mo->reftype to get the bare reference type of anything. * Added mo->class to get the class of anything. * Added mo->ISA to return @ISA. * Added mo->super to call a method in a super class. * Added mo->linear_isa to get the object's inheritance path. * Introduced perl5i::latest to use the latest version. * Added %hash->flip() and %hash->merge() (brunov) * @array->grep now takes a regex * Select methods from List::MoreUtils added as ARRAY methods. all, any, none, true, false, uniq, minmax, mesh. * Added @array->diff() (brunov) * "use utf8" is on by default. * STDOUT, STDIN, STDERR and all opened filehandles have utf8 encoding on. * @ARGV is encoded as UTF8 * Added methods to determine if a scalar is a number and what kind it is. * Added ceil()/floor() and round_up()/round_down() synonyms. Docs * Various POD fixes (chromatic, Richard Soderberg) * Collected together the autoboxed methods Other * Look, a changes document! * Added a patching policy. See the PATCHING file. * We have a mailing list now. http://groups.google.com/group/perl5i 0.1.0 Sat Jan 23 14:55:52 2010 -0800 * Return to CPAN after deleting 20090424 * New versioning scheme so we can declare incompatibilities, see semver.org for details. If you have perl5i installed you must force an upgrade. * Thanks to the Open Source Bridge perl5i Hackathon! Incompatible Changes * Switched to DateTime from Time::Piece New Features * List::Util now autoboxed (Chas) * time() returns a DateTime object (schwern) * Added alias() (schwern) * Now y2038 safe (schwern) * die always returns 255 regardless of $! or $? (Chas) * Added a perl5i command line program (dap) * Add $CWD for localized chdir'ing via File::chdir (schwern) * Add $scalar->center() (chromatic, benh) * Add $scalar->ltrim(), ->rtrim() and trim() (benh) * Add $scalar->wrap() via Text::Wrap (brunov) * Automatic "use English" (schwern) * Automatic "use IO::Handle" so things like autoflush are available (schwern) * Automatic "use Want" (Jeff Lavallee) * Automatic "no autovivification" (schwern) Bug Fixes * stat() works in list context (schwern) 20090424 Fri Apr 24 11:38:24 2009 -0700 * First release perl5i-v2.12.0/INSTALL.SKIP000444000765000024 2112155475023 15007 0ustar00schwernstaff000000000000\.PL$ \.c$ \.o$ perl5i-v2.12.0/LICENSE000444000765000024 4376612155475023 14325 0ustar00schwernstaff000000000000This software is copyright (c) 2013 by Michael G Schwern . 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) 2013 by Michael G Schwern . 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, Suite 500, Boston, MA 02110-1335 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) 2013 by Michael G Schwern . 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 perl5i-v2.12.0/local-lib-rc000444000765000024 44312155475023 15424 0ustar00schwernstaff000000000000# Write to $HOME/.local-lib-rc and then add # "source ~/.local-lib-rc" to $HOME/.bashrc export PERL_MB_OPT="--install_base $HOME/perl5" export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" export PERL5LIB="$HOME/perl5/lib/perl5/i386-linux:$HOME/perl5/lib/perl5" export PATH="$HOME/perl5/bin:$PATH" perl5i-v2.12.0/MANIFEST000444000765000024 552312155475023 14416 0ustar00schwernstaff000000000000.perlcriticrc .perltidyrc bin/perl5i.bat.PL bin/perl5i.c.PL bin/perl5i.plx Build.PL Changes inc/MyBuild.pm INSTALL.SKIP lib/perl5i.pm lib/perl5i/0.pm lib/perl5i/0/ARRAY.pm lib/perl5i/0/DateTime.pm lib/perl5i/0/DEFAULT.pm lib/perl5i/0/HASH.pm lib/perl5i/0/Meta.pm lib/perl5i/0/Meta/Class.pm lib/perl5i/0/Meta/Instance.pm lib/perl5i/0/SCALAR.pm lib/perl5i/1.pm lib/perl5i/1/ARRAY.pm lib/perl5i/1/autobox.pm lib/perl5i/1/CODE.pm lib/perl5i/1/DateTime.pm lib/perl5i/1/HASH.pm lib/perl5i/1/Meta.pm lib/perl5i/1/Meta/Class.pm lib/perl5i/1/Meta/Instance.pm lib/perl5i/1/SCALAR.pm lib/perl5i/1/UNIVERSAL.pm lib/perl5i/2.pm lib/perl5i/2/ARRAY.pm lib/perl5i/2/autobox.pm lib/perl5i/2/CODE.pm lib/perl5i/2/DateTime.pm lib/perl5i/2/equal.pm lib/perl5i/2/HASH.pm lib/perl5i/2/Meta.pm lib/perl5i/2/Meta/Class.pm lib/perl5i/2/Meta/Instance.pm lib/perl5i/2/RequireMessage.pm lib/perl5i/2/SCALAR.pm lib/perl5i/2/Signature.pm lib/perl5i/2/Signature/Function/None.pm lib/perl5i/2/Signature/Method/None.pm lib/perl5i/2/Signature/None.pm lib/perl5i/2/Signature/Real.pm lib/perl5i/2/Signatures.pm lib/perl5i/2/UNIVERSAL.pm lib/perl5i/cmd.pm lib/perl5i/latest.pm lib/perl5i/Meta.pod lib/perl5i/Signature.pod lib/perl5i/VERSION.pm lib/perl5ifaq.pod LICENSE local-lib-rc MANIFEST This list of files MANIFEST.SKIP META.json META.yml PATCHING README t/alias.t t/ARGV.t t/ARGV_twice.t t/as_hash.t t/autobox.t t/autodie.t t/autovivification.t t/caller.t t/can.t t/capture.t t/carp.t t/center.t t/chdir.t t/Child.t t/CLASS.t t/command_line_wrapper.t t/commify.t t/datetime.t t/die.t t/diff.t t/dump/array.t t/dump/code.t t/dump/formats.t t/dump/hash.t t/dump/obj.t t/dump/scalar.t t/each.t t/English.t t/equal.t t/everything_is_an_object.t t/File-stat.t t/flip.t t/foreach.t t/github164.t t/grep.t t/hash-diff.t t/hash-intersect.t t/hash-merge.t t/intersect.t t/io-handle.t t/is_module_name.t t/lexical.t t/lib/Test/perl5i.pm t/lib/ThisIsTrue.pm t/List-MoreUtils/all.t t/List-MoreUtils/any.t t/List-MoreUtils/false.t t/List-MoreUtils/mesh.t t/List-MoreUtils/minmax.t t/List-MoreUtils/none.t t/List-MoreUtils/true.t t/List-MoreUtils/uniq.t t/list-trim.t t/List-Util/first.t t/List-Util/max.t t/List-Util/maxstr.t t/List-Util/min.t t/List-Util/minstr.t t/List-Util/reduce.t t/List-Util/shuffle.t t/List-Util/sum.t t/list.t t/load_together.t t/map.t t/Meta/checksum.t t/Meta/class.t t/Meta/id.t t/Meta/is-equal.t t/Meta/ISA.t t/Meta/linear_isa.t t/Meta/methods.t t/Meta/reftype.t t/Meta/super.t t/Meta/symbol_table.t t/method_leaking.t t/modern_perl.t t/module2path.t t/no_indirect.t t/number.t t/perl5i.t t/pick.t t/popn.t t/require.t t/require_message.t t/say.t t/scalar.t t/shiftn.t t/signature.t t/signatures.t t/skip.t t/taint.t t/time_compat.t t/true.t t/try-tiny.t t/uniq.t t/utf8.t t/version_0/00_compile.t t/version_1/00_compile.t t/vs_listmoreutils.t t/Want.t t/wrap.t t/y2038.t SIGNATURE Added here by Module::Build perl5i-v2.12.0/MANIFEST.SKIP000444000765000024 266212155475023 15164 0ustar00schwernstaff000000000000 #!start included /Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/ExtUtils/MANIFEST.SKIP # Avoid Devel::NYTProf files ^nytprof # Don't ship perl5i ^bin/perl5i$ ^bin/perl5i.c$ ^bin/perl5i.bat$ # Ignore C object files \.o$ ^MYMETA.yml$ # Ignore emacs temp files ^\.# # Ignore our own dist dir ^perl5i- # Don't ship admin scripts ^admin/ # Don't ship our motivational images ^img/ # Don't ship patch files \.patch$ \.diff$ # Don't ship the test template t/00_TEST_TEMPLATE.t # Don't ship Travis-CI config ^\.travis\.ymlperl5i-v2.12.0/META.json000444000765000024 2126212155475023 14724 0ustar00schwernstaff000000000000{ "abstract" : "Fix as much of Perl 5 as possible in one pragma", "author" : [ "Michael G Schwern " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4004, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "perl5i", "no_index" : { "file" : [ "lib/perl5i/0/DateTime.pm", "lib/perl5i/0/ARRAY.pm", "lib/perl5i/0/DEFAULT.pm", "lib/perl5i/0/HASH.pm", "lib/perl5i/0/Meta.pm", "lib/perl5i/0/Meta/Class.pm", "lib/perl5i/0/Meta/Instance.pm", "lib/perl5i/0/SCALAR.pm", "lib/perl5i/VERSION.pm" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::CBuilder" : "0.26", "IPC::Open3" : "0", "Test::More" : "0.88", "Test::Output" : "0.16", "Test::Warn" : "0.11" } }, "configure" : { "requires" : { "Module::Build" : "0.36" } }, "runtime" : { "requires" : { "CLASS" : "1.00", "Capture::Tiny" : "0.06", "Carp::Fix::1_25" : "1.000000", "Child" : "0.009", "DateTime" : "0.47", "DateTime::Format::Epoch" : "0.11", "DateTime::TimeZone::Tzfile" : "0.002", "Devel::Declare::MethodInstaller::Simple" : "0.006009", "Digest::MD5" : "2.36", "Digest::SHA" : "5.45", "File::chdir" : "0.1002", "Hash::FieldHash" : "0.06", "Hash::Merge::Simple" : "0.04", "Hash::StoredIterator" : "0.005", "IPC::System::Simple" : "1.18", "JSON" : "2.17", "List::MoreUtils" : "0.22", "Modern::Perl" : "1.03", "Module::Load" : "0.16", "Object::ID" : "v0.1.0", "Perl6::Caller" : "0.100", "Taint::Util" : "0.06", "Text::Wrap" : "2009.0305", "Try::Tiny" : "0.02", "Want" : "0.18", "YAML::Any" : "0.70", "autobox" : "2.70", "autobox::Core" : "1.0", "autobox::List::Util" : "20090629", "autobox::dump" : "20090426", "autodie" : "2.12", "autovivification" : "0.06", "indirect" : "0.24", "parent" : "0.221", "perl" : "v5.10.0", "true::VERSION" : "0.16", "utf8::all" : "0.002", "version" : "0.77" } } }, "provides" : { "perl5i" : { "file" : "lib/perl5i.pm", "version" : "v2.12.0" }, "perl5i::0" : { "file" : "lib/perl5i/0.pm", "version" : "v2.12.0" }, "perl5i::0::ARRAY" : { "file" : "lib/perl5i/0/ARRAY.pm", "version" : 0 }, "perl5i::0::DEFAULT" : { "file" : "lib/perl5i/0/DEFAULT.pm", "version" : 0 }, "perl5i::0::DateTime" : { "file" : "lib/perl5i/0/DateTime.pm", "version" : 0 }, "perl5i::0::DateTime::Format::CTime" : { "file" : "lib/perl5i/0/DateTime.pm", "version" : 0 }, "perl5i::0::DateTime::time" : { "file" : "lib/perl5i/0/DateTime.pm", "version" : 0 }, "perl5i::0::DateTime::y2038" : { "file" : "lib/perl5i/0/DateTime.pm", "version" : 0 }, "perl5i::0::HASH" : { "file" : "lib/perl5i/0/HASH.pm", "version" : 0 }, "perl5i::0::Meta" : { "file" : "lib/perl5i/0/Meta.pm", "version" : 0 }, "perl5i::0::Meta::Class" : { "file" : "lib/perl5i/0/Meta/Class.pm", "version" : 0 }, "perl5i::0::Meta::Instance" : { "file" : "lib/perl5i/0/Meta/Instance.pm", "version" : 0 }, "perl5i::0::SCALAR" : { "file" : "lib/perl5i/0/SCALAR.pm", "version" : 0 }, "perl5i::1" : { "file" : "lib/perl5i/1.pm", "version" : "v2.12.0" }, "perl5i::1::ARRAY" : { "file" : "lib/perl5i/1/ARRAY.pm", "version" : 0 }, "perl5i::1::CODE" : { "file" : "lib/perl5i/1/CODE.pm", "version" : 0 }, "perl5i::1::DateTime" : { "file" : "lib/perl5i/1/DateTime.pm", "version" : 0 }, "perl5i::1::DateTime::Format::CTime" : { "file" : "lib/perl5i/1/DateTime.pm", "version" : 0 }, "perl5i::1::DateTime::time" : { "file" : "lib/perl5i/1/DateTime.pm", "version" : 0 }, "perl5i::1::DateTime::y2038" : { "file" : "lib/perl5i/1/DateTime.pm", "version" : 0 }, "perl5i::1::HASH" : { "file" : "lib/perl5i/1/HASH.pm", "version" : 0 }, "perl5i::1::Meta" : { "file" : "lib/perl5i/1/Meta.pm", "version" : 0 }, "perl5i::1::Meta::Class" : { "file" : "lib/perl5i/1/Meta/Class.pm", "version" : 0 }, "perl5i::1::Meta::Instance" : { "file" : "lib/perl5i/1/Meta/Instance.pm", "version" : 0 }, "perl5i::1::SCALAR" : { "file" : "lib/perl5i/1/SCALAR.pm", "version" : 0 }, "perl5i::1::UNIVERSAL" : { "file" : "lib/perl5i/1/UNIVERSAL.pm", "version" : 0 }, "perl5i::1::autobox" : { "file" : "lib/perl5i/1/autobox.pm", "version" : 0 }, "perl5i::2" : { "file" : "lib/perl5i/2.pm", "version" : "v2.12.0" }, "perl5i::2::ARRAY" : { "file" : "lib/perl5i/2/ARRAY.pm", "version" : 0 }, "perl5i::2::CODE" : { "file" : "lib/perl5i/2/CODE.pm", "version" : 0 }, "perl5i::2::DateTime" : { "file" : "lib/perl5i/2/DateTime.pm", "version" : 0 }, "perl5i::2::DateTime::Format::CTime" : { "file" : "lib/perl5i/2/DateTime.pm", "version" : 0 }, "perl5i::2::DateTime::time" : { "file" : "lib/perl5i/2/DateTime.pm", "version" : 0 }, "perl5i::2::DateTime::y2038" : { "file" : "lib/perl5i/2/DateTime.pm", "version" : 0 }, "perl5i::2::HASH" : { "file" : "lib/perl5i/2/HASH.pm", "version" : 0 }, "perl5i::2::Meta" : { "file" : "lib/perl5i/2/Meta.pm", "version" : 0 }, "perl5i::2::Meta::Class" : { "file" : "lib/perl5i/2/Meta/Class.pm", "version" : 0 }, "perl5i::2::Meta::Instance" : { "file" : "lib/perl5i/2/Meta/Instance.pm", "version" : 0 }, "perl5i::2::RequireMessage" : { "file" : "lib/perl5i/2/RequireMessage.pm", "version" : 0 }, "perl5i::2::SCALAR" : { "file" : "lib/perl5i/2/SCALAR.pm", "version" : 0 }, "perl5i::2::Signature" : { "file" : "lib/perl5i/2/Signature.pm", "version" : 0 }, "perl5i::2::Signature::Function::None" : { "file" : "lib/perl5i/2/Signature/Function/None.pm", "version" : 0 }, "perl5i::2::Signature::Method::None" : { "file" : "lib/perl5i/2/Signature/Method/None.pm", "version" : 0 }, "perl5i::2::Signature::None" : { "file" : "lib/perl5i/2/Signature/None.pm", "version" : 0 }, "perl5i::2::Signature::Real" : { "file" : "lib/perl5i/2/Signature/Real.pm", "version" : 0 }, "perl5i::2::Signatures" : { "file" : "lib/perl5i/2/Signatures.pm", "version" : 0 }, "perl5i::2::UNIVERSAL" : { "file" : "lib/perl5i/2/UNIVERSAL.pm", "version" : 0 }, "perl5i::2::autobox" : { "file" : "lib/perl5i/2/autobox.pm", "version" : 0 }, "perl5i::2::equal" : { "file" : "lib/perl5i/2/equal.pm", "version" : 0 }, "perl5i::VERSION" : { "file" : "lib/perl5i/VERSION.pm", "version" : "v2.12.0" }, "perl5i::cmd" : { "file" : "lib/perl5i/cmd.pm", "version" : 0 }, "perl5i::latest" : { "file" : "lib/perl5i/latest.pm", "version" : "v2.12.0" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://github.com/schwern/perl5i/issues" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/schwern/perl5i/tree/master" }, "x_Chat" : "irc://irc.perl.org/#perl5i" }, "version" : "v2.12.0" } perl5i-v2.12.0/META.yml000444000765000024 1313112155475023 14550 0ustar00schwernstaff000000000000--- abstract: 'Fix as much of Perl 5 as possible in one pragma' author: - 'Michael G Schwern ' build_requires: ExtUtils::CBuilder: 0.26 IPC::Open3: 0 Test::More: 0.88 Test::Output: 0.16 Test::Warn: 0.11 configure_requires: Module::Build: 0.36 dynamic_config: 1 generated_by: 'Module::Build version 0.4004, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: perl5i no_index: file: - lib/perl5i/0/DateTime.pm - lib/perl5i/0/ARRAY.pm - lib/perl5i/0/DEFAULT.pm - lib/perl5i/0/HASH.pm - lib/perl5i/0/Meta.pm - lib/perl5i/0/Meta/Class.pm - lib/perl5i/0/Meta/Instance.pm - lib/perl5i/0/SCALAR.pm - lib/perl5i/VERSION.pm provides: perl5i: file: lib/perl5i.pm version: v2.12.0 perl5i::0: file: lib/perl5i/0.pm version: v2.12.0 perl5i::0::ARRAY: file: lib/perl5i/0/ARRAY.pm version: 0 perl5i::0::DEFAULT: file: lib/perl5i/0/DEFAULT.pm version: 0 perl5i::0::DateTime: file: lib/perl5i/0/DateTime.pm version: 0 perl5i::0::DateTime::Format::CTime: file: lib/perl5i/0/DateTime.pm version: 0 perl5i::0::DateTime::time: file: lib/perl5i/0/DateTime.pm version: 0 perl5i::0::DateTime::y2038: file: lib/perl5i/0/DateTime.pm version: 0 perl5i::0::HASH: file: lib/perl5i/0/HASH.pm version: 0 perl5i::0::Meta: file: lib/perl5i/0/Meta.pm version: 0 perl5i::0::Meta::Class: file: lib/perl5i/0/Meta/Class.pm version: 0 perl5i::0::Meta::Instance: file: lib/perl5i/0/Meta/Instance.pm version: 0 perl5i::0::SCALAR: file: lib/perl5i/0/SCALAR.pm version: 0 perl5i::1: file: lib/perl5i/1.pm version: v2.12.0 perl5i::1::ARRAY: file: lib/perl5i/1/ARRAY.pm version: 0 perl5i::1::CODE: file: lib/perl5i/1/CODE.pm version: 0 perl5i::1::DateTime: file: lib/perl5i/1/DateTime.pm version: 0 perl5i::1::DateTime::Format::CTime: file: lib/perl5i/1/DateTime.pm version: 0 perl5i::1::DateTime::time: file: lib/perl5i/1/DateTime.pm version: 0 perl5i::1::DateTime::y2038: file: lib/perl5i/1/DateTime.pm version: 0 perl5i::1::HASH: file: lib/perl5i/1/HASH.pm version: 0 perl5i::1::Meta: file: lib/perl5i/1/Meta.pm version: 0 perl5i::1::Meta::Class: file: lib/perl5i/1/Meta/Class.pm version: 0 perl5i::1::Meta::Instance: file: lib/perl5i/1/Meta/Instance.pm version: 0 perl5i::1::SCALAR: file: lib/perl5i/1/SCALAR.pm version: 0 perl5i::1::UNIVERSAL: file: lib/perl5i/1/UNIVERSAL.pm version: 0 perl5i::1::autobox: file: lib/perl5i/1/autobox.pm version: 0 perl5i::2: file: lib/perl5i/2.pm version: v2.12.0 perl5i::2::ARRAY: file: lib/perl5i/2/ARRAY.pm version: 0 perl5i::2::CODE: file: lib/perl5i/2/CODE.pm version: 0 perl5i::2::DateTime: file: lib/perl5i/2/DateTime.pm version: 0 perl5i::2::DateTime::Format::CTime: file: lib/perl5i/2/DateTime.pm version: 0 perl5i::2::DateTime::time: file: lib/perl5i/2/DateTime.pm version: 0 perl5i::2::DateTime::y2038: file: lib/perl5i/2/DateTime.pm version: 0 perl5i::2::HASH: file: lib/perl5i/2/HASH.pm version: 0 perl5i::2::Meta: file: lib/perl5i/2/Meta.pm version: 0 perl5i::2::Meta::Class: file: lib/perl5i/2/Meta/Class.pm version: 0 perl5i::2::Meta::Instance: file: lib/perl5i/2/Meta/Instance.pm version: 0 perl5i::2::RequireMessage: file: lib/perl5i/2/RequireMessage.pm version: 0 perl5i::2::SCALAR: file: lib/perl5i/2/SCALAR.pm version: 0 perl5i::2::Signature: file: lib/perl5i/2/Signature.pm version: 0 perl5i::2::Signature::Function::None: file: lib/perl5i/2/Signature/Function/None.pm version: 0 perl5i::2::Signature::Method::None: file: lib/perl5i/2/Signature/Method/None.pm version: 0 perl5i::2::Signature::None: file: lib/perl5i/2/Signature/None.pm version: 0 perl5i::2::Signature::Real: file: lib/perl5i/2/Signature/Real.pm version: 0 perl5i::2::Signatures: file: lib/perl5i/2/Signatures.pm version: 0 perl5i::2::UNIVERSAL: file: lib/perl5i/2/UNIVERSAL.pm version: 0 perl5i::2::autobox: file: lib/perl5i/2/autobox.pm version: 0 perl5i::2::equal: file: lib/perl5i/2/equal.pm version: 0 perl5i::VERSION: file: lib/perl5i/VERSION.pm version: v2.12.0 perl5i::cmd: file: lib/perl5i/cmd.pm version: 0 perl5i::latest: file: lib/perl5i/latest.pm version: v2.12.0 requires: CLASS: 1.00 Capture::Tiny: 0.06 Carp::Fix::1_25: 1.000000 Child: 0.009 DateTime: 0.47 DateTime::Format::Epoch: 0.11 DateTime::TimeZone::Tzfile: 0.002 Devel::Declare::MethodInstaller::Simple: 0.006009 Digest::MD5: 2.36 Digest::SHA: 5.45 File::chdir: 0.1002 Hash::FieldHash: 0.06 Hash::Merge::Simple: 0.04 Hash::StoredIterator: 0.005 IPC::System::Simple: 1.18 JSON: 2.17 List::MoreUtils: 0.22 Modern::Perl: 1.03 Module::Load: 0.16 Object::ID: v0.1.0 Perl6::Caller: 0.100 Taint::Util: 0.06 Text::Wrap: 2009.0305 Try::Tiny: 0.02 Want: 0.18 YAML::Any: 0.70 autobox: 2.70 autobox::Core: 1.0 autobox::List::Util: 20090629 autobox::dump: 20090426 autodie: 2.12 autovivification: 0.06 indirect: 0.24 parent: 0.221 perl: v5.10.0 true::VERSION: 0.16 utf8::all: 0.002 version: 0.77 resources: bugtracker: http://github.com/schwern/perl5i/issues license: http://dev.perl.org/licenses/ repository: http://github.com/schwern/perl5i/tree/master x_Chat: irc://irc.perl.org/#perl5i version: v2.12.0 perl5i-v2.12.0/PATCHING000444000765000024 454612155475023 14411 0ustar00schwernstaff000000000000Patching policy for perl5i. For the really impatient: ------------------------- * Rule 1: When in doubt, open a ticket. http://github.com/schwern/perl5i/issues Found a bug? Not sure if its a bug or a weird feature? Have an idea? Found something unpleasent? Had trouble using something? Open a ticket. Don't worry, we won't yell at you. We'd rather get 10 duplicates than lose one good report because somebody wasn't sure. * We prefer if you use github, but you can always email a patch to perl5i@googlegroups.com. * Don't know if your code is up to our standard? Send it in and we'll work it out. * perl5i is about making Perl 5 better. A good rule of thumb is if it takes more than one line to do a simple thing, you might be on to something. If a newbie asks a simple question and the "right answer" takes a full page, you've probably found a candidate for perl5i. Here's the preferred way to make a patch: ---------------------------------------- 0) We'd rather you participate than follow all the rules, especially if its your first patch. Don't worry, be crappy. 1) Put an issue in the tracker for your problem. Then it can be discussed before you put a whole lot of effort into it. http://github.com/schwern/perl5i/issues 1a) If its a bug, report the bug BEFORE work on it. This ensures the bug gets reported. Mention that you're working on it. 1b) If its a feature, we like to hear about your idea even if you don't have a patch. 2) You can either work from the CPAN version or the repository. We'd prefer you worked from the repository. http://github.com/schwern/perl5i 2a) Ideally, make a fork on github and work on that. 3) DO add any new dependencies in Build.PL 3a) If you're not sure what version to depend on, pick the version you have installed. That's safest. 4) DON'T update MANIFEST. Its automated and will just cause conflicts. 5) DON'T update Changes. It will cause conflicts when merging. The release manager will handle it. 6) DO write tests. Otherwise the release manager has to. 7) DO write documentation. Otherwise the release manager has to. 8) Commit ONE THING AT A TIME. Preferrably use a branch for each feature. It makes it much easier to integrate. 9) You can either send patches to schwern+perl5i@pobox.com or (preferred) issue a github pull request. Thanks for patching! perl5i-v2.12.0/README000444000765000024 10057012155475023 14203 0ustar00schwernstaff000000000000NAME perl5i - Fix as much of Perl 5 as possible in one pragma SYNOPSIS use perl5i::2; or $ perl5i your_script.pl DESCRIPTION Perl 5 has a lot of warts. There's a lot of individual modules and techniques out there to fix those warts. perl5i aims to pull the best of them together into one module so you can turn them on all at once. This includes adding features, changing existing core functions and changing defaults. It will likely not be 100% backwards compatible with Perl 5, though it will be 99%, perl5i will try to have a lexical effect. Please add to this imaginary world and help make it real, either by telling me what Perl looks like in your imagination (http://github.com/schwern/perl5i/issues) or make a fork (forking on github is like a branch you control) and implement it yourself. Using perl5i Because perl5i *plans* to be incompatible in the future, you do not simply "use perl5i". You must declare which major version of perl5i you are using. You do this like so: # Use perl5i major version 2 use perl5i::2; Thus the code you write with, for example, "perl5i::2" will always remain compatible even as perl5i moves on. If you want to be daring, you can "use perl5i::latest" to get the latest version. This will automatically happen if the program is "-e". This lets you do slightly less typing for one-liners like "perl -Mperl5i -e ..." If you want your module to depend on perl5i, you should depend on the versioned class. For example, depend on "perl5i::2" and not "perl5i". See "VERSIONING" for more information about perl5i's versioning scheme. What it does perl5i enables each of these modules and adds/changes these functions. We'll provide a brief description here, but you should look at each of their documentation for full details. The Meta Object Every object (and everything is an object) now has a meta object associated with it. Using the meta object you can ask things about the object which were previously over complicated. For example... # the object's class my $class = $obj->mo->class; # its parent classes my @isa = $obj->mo->isa; # the complete inheritance hierarchy my @complete_isa = $obj->mo->linear_isa; # the reference type of the object my $reftype = $obj->mo->reftype; A meta object is used to avoid polluting the global method space. "mo" was chosen to avoid clashing with Moose's meta object. See perl5i::Meta for complete details. Subroutine and Method Signatures perl5i makes it easier to declare what parameters a subroutine takes. func hello($place) { say "Hello, $place!\n"; } method get($key) { return $self->{$key}; } method new($class: %args) { return bless \%args, $class; } "func" and "method" define subroutines as "sub" does, with some extra conveniences. The signature syntax is currently very simple. The content will be assigned from @_. This: func add($this, $that) { return $this + $that; } is equivalent to: sub add { my($this, $that) = @_; return $this + $that; } "method" defines a method. This is the same as a subroutine, but the first argument, the *invocant*, will be removed and made into $self. method get($key) { return $self->{$key}; } sub get { my $self = shift; my($key) = @_; return $self->{$key}; } Methods have a special bit of syntax. If the first item in the siganture is $var: it will change the variable used to store the invocant. method new($class: %args) { return bless \%args, $class; } is equivalent to: sub new { my $class = shift; my %args = @_; return bless \%args, $class; } Anonymous functions and methods work, too. my $code = func($message) { say $message }; Guarantees include: @_ will not be modified except by removing the invocant Future versions of perl5i will add to the signature syntax and capabilities. Planned expansions include: Signature validation Signature documentation Named parameters Required parameters Read only parameters Aliased parameters Anonymous method and function declaration Variable method and function names Parameter traits Traditional prototypes See for more details about future expansions. The equivalencies above should only be taken for illustrative purposes, they are not guaranteed to be literally equivalent. Note that while all parameters are optional by default, the number of parameters will eventually be enforced. For example, right now this will work: func add($this, $that) { return $this + $that } say add(1,2,3); # says 3 The extra argument is ignored. In future versions of perl5i this will be a runtime error. Signature Introspection The signature of a subroutine defined with "func" or "method" can be queried by calling the "signature" method on the code reference. func hello($greeting, $place) { say "$greeting, $place" } my $code = \&hello; say $code->signature->num_positional_params; # prints 2 Functions defined with "sub" will not have a signature. See perl5i::Signature for more details. Autoboxing autobox allows methods to be defined for and called on most unblessed variables. This means you can call methods on ordinary strings, lists and hashes! It also means perl5i can add a lot of functionality without polluting the global namespace. autobox::Core wraps a lot of Perl's built in functions so they can be called as methods on unblessed variables. "@a->pop" for example. alias $scalar_reference->alias( @identifiers ); @alias->alias( @identifiers ); %hash->alias( @identifiers ); (\&code)->alias( @identifiers ); Aliases a variable to a new global name. my $code = sub { 42 }; $code->alias( "foo" ); say foo(); # prints 42 It will work on everything except scalar references. our %stuff; %other_hash->alias( "stuff" ); # %stuff now aliased to %other_hash It is not a copy, changes to one will change the other. my %things = (foo => 23); our %stuff; %things->alias( "stuff" ); # alias %things to %stuff $stuff{foo} = 42; # change %stuff say $things{foo}; # and it will show up in %things Multiple @identifiers will be joined with '::' and used as the fully qualified name for the alias. my $class = "Some::Class"; my $name = "foo"; sub { 99 }->alias( $class, $name ); say Some::Class->foo; # prints 99 If there is just one @identifier and it has no "::" in it, the current caller will be prepended. "$thing->alias("name")" is shorthand for "$thing->alias(CLASS, "name")" Due to limitations in autobox, non-reference scalars cannot be aliased. Alias a scalar ref instead. my $thing = 23; $thing->alias("foo"); # error my $thing = \23; $thing->alias("foo"); # $foo is now aliased to $thing This is basically a nicer way to say: no strict 'refs'; *{$package . '::'. $name} = $reference; Scalar Autoboxing All of the methods provided by autobox::Core are available from perl5i. in addition, perl5i adds some methods of its own. center my $centered_string = $string->center($length); my $centered_string = $string->center($length, $character); Centers $string between $character. $centered_string will be of length $length. $character defaults to " ". say "Hello"->center(10); # " Hello "; say "Hello"->center(10, '-'); # "---Hello--"; "center()" will never truncate $string. If $length is less than "$string->length" it will just return $string. say "Hello"->center(4); # "Hello"; round my $rounded_number = $number->round; Round to the nearest integer. round_up ceil my $new_number = $number->round_up; Rounds the $number towards infinity. 2.45->round_up; # 3 (-2.45)->round_up; # -2 ceil() is a synonym for round_up(). round_down floor my $new_number = $number->round_down; Rounds the $number towards negative infinity. 2.45->round_down; # 2 (-2.45)->round_down; # -3 floor() is a synonyn for round_down(). is_number $is_a_number = $thing->is_number; Returns true if $thing is a number understood by Perl. 12.34->is_number; # true "12.34"->is_number; # also true "eleven"->is_number; # false is_positive $is_positive = $thing->is_positive; Returns true if $thing is a positive number. 0 is not positive. is_negative $is_negative = $thing->is_negative; Returns true if $thing is a negative number. 0 is not negative. is_even $is_even = $thing->is_even; Returns true if $thing is an even integer. is_odd $is_odd = $thing->is_odd; Returns true if $thing is an odd integer. is_integer $is_an_integer = $thing->is_integer; Returns true if $thing is an integer. 12->is_integer; # true 12.34->is_integer; # false "eleven"->is_integer; # false is_int A synonym for is_integer is_decimal $is_a_decimal_number = $thing->is_decimal; Returns true if $thing is a decimal number. 12->is_decimal; # false 12.34->is_decimal; # true ".34"->is_decimal; # true "point five"->is_decimal; # false require my $module = $module->require; Will "require" the given $module. This avoids funny things like "eval qq[require $module] or die $@". It accepts only module names. On failure it will throw an exception, just like "require". On a success it returns the $module. This is mostly useful so that you can immediately call $module's "import" method to emulate a "use". # like "use $module qw(foo bar);" if that worked $module->require->import(qw(foo bar)); # like "use $module;" if that worked $module->require->import; wrap my $wrapped = $string->wrap( width => $cols, separator => $sep ); Wraps $string to width $cols, breaking lines at word boundries using separator $sep. If no width is given, $cols defaults to 76. Default line separator is the newline character "\n". See Text::Wrap for details. ltrim rtrim trim my $trimmed = $string->trim; my $trimmed = $string->trim($character_set); Trim whitespace. ltrim() trims off the start of the string (left), rtrim() off the end (right) and trim() off both the start and end. my $string = ' testme'->ltrim; # 'testme' my $string = 'testme '->rtrim; # 'testme' my $string = ' testme '->trim; # 'testme' They all take an optional $character_set which will determine what characters should be trimmed. It follows regex character set syntax so "A-Z" will trim everything from A to Z. Defaults to "\s", whitespace. my $string = '-> test <-'->trim('-><'); # ' test ' title_case my $name = 'joe smith'->title_case; # Joe Smith Will uppercase every word character that follows a wordbreak character. path2module my $module = $path->path2module; Given a relative $path it will return the Perl module this represents. For example, "Foo/Bar.pm"->path2module; # "Foo::Bar" It will throw an exception if given something which could not be a path to a Perl module. module2path my $path = $module->module2path; Will return the relative $path in which the Perl $module can be found. For example, "Foo::Bar"->module2path; # "Foo/Bar.pm" is_module_name my $is_valid = $string->is_module_name; Will return true if the $string is a valid module name. "Foo::Bar"->is_module_name; # true "Foo/Bar"->is_module_name; # false group_digits my $number_grouped = $number->group_digits; my $number_grouped = $number->group_digits(\%options); Turns a number like 1234567 into a string like 1,234,567 known as "digit grouping". It honors your current locale to determine the separator and grouping. This can be overridden using %options. NOTE: many systems do not have their numeric locales set properly separator The character used to separate groups. Defaults to "thousands_sep" in your locale or "," if your locale doesn't specify. decimal_point The decimal point character. Defaults to "decimal_point" in your locale or "." if your locale does not specify. grouping How many numbers in a group? Defaults to "grouping" in your locale or 3 if your locale doesn't specify. Note: we don't honor the full grouping locale, its a wee bit too complicated. currency If true, it will treat the number as currency and use the monetary locale settings. "mon_thousands_sep" instead of "thousands_sep" and "mon_grouping" instead of "grouping". 1234->group_digits; # 1,234 (assuming US locale) 1234->group_digits( separator => "." ); # 1.234 commify my $number_grouped = $number->commify; my $number_grouped = $number->commify(\%options); commify() is just like group_digits() but it is not locale aware. It is useful when you want a predictable result regardless of the user's locale settings. %options defaults to "( separator => ",", grouping => 3, decimal_point => "." )". Each key will be overridden individually. 1234->commify; # 1,234 1234->commify({ separator => "." }); # 1.234 reverse my $reverse = $string->reverse; Reverses a $string. Unlike Perl's reverse(), this always reverses the string regardless of context. Array Autoboxing The methods provided by "Array Methods" in autobox::Core are available from perl5i. All the functions from List::Util and select ones from List::MoreUtils are all available as methods on unblessed arrays and array refs: first, max, maxstr, min, minstr, minmax, shuffle, reduce, sum, any, all, none, true, false, uniq and mesh. They have all been altered to return array refs where applicable in order to allow chaining. @array->grep(sub{ $_->is_number })->sum->say; foreach @array->foreach( func($item) { ... } ); Works like the built in "foreach", calls the code block for each element of @array passing it into the block. @array->foreach( func($item) { say $item } ); # print each item It will pass in as many elements as the code block accepts. This allows you to iterate through an array 2 at a time, or 3 or 4 or whatever. my @names = ("Joe", "Smith", "Jim", "Dandy", "Jane", "Lane"); @names->foreach( func($fname, $lname) { say "Person: $fname $lname"; }); A normal subroutine with no signature will get one at a time. If @array is not a multiple of the iteration (for example, @array has 5 elements and you ask 2 at a time) the behavior is currently undefined. as_hash my %hash = @array->as_hash; This method returns a %hash where each element of @array is a key. The values are all true. Its functionality is similar to: my %hash = map { $_ => 1 } @array; Example usage: my @array = ("a", "b", "c"); my %hash = @array->as_hash; say q[@array contains 'a'] if $hash{"a"}; pick my @rand = @array->pick($number); The pick() method returns a list of $number elements in @array. If $number is larger than the size of the list, it returns the entire list shuffled. Example usage: my @array = (1, 2, 3, 4); my @rand = @array->pick(2); pick_one my $rand = @array->pick_one; The pick_one() method returns a random element in @array. It is similar to @array->pick(1), except that it does not return a list. Example usage: my @array = (1,2,3,4); my $rand = @array->pick_one; diff Calculate the difference between two (or more) arrays: my @a = ( 1, 2, 3 ); my @b = ( 3, 4, 5 ); my @diff_a = @a->diff(\@b) # [ 1, 2 ] my @diff_b = @b->diff(\@a) # [ 4, 5 ] Diff returns all elements in array @a that are not present in array @b. Item order is not considered: two identical elements in both arrays will be recognized as such disregarding their index. [ qw( foo bar ) ]->diff( [ qw( bar foo ) ] ) # empty, they are equal For comparing more than two arrays: @a->diff(\@b, \@c, ... ) All comparisons are against the base array (@a in this example). The result will be composed of all those elements that were present in @a and in none other. It also works with nested data structures; it will traverse them depth-first to assess whether they are identical or not. For instance: [ [ 'foo ' ], { bar => 1 } ]->diff([ 'foo' ]) # [ { bar => 1 } ] In the case of overloaded objects (i.e., DateTime, URI, Path::Class, etc.), it tries its best to treat them as strings or numbers. my $uri = URI->new("http://www.perl.com"); my $uri2 = URI->new("http://www.perl.com"); [ $uri ]->diff( [ "http://www.perl.com" ] ); # empty, they are equal [ $uri ]->diff( [ $uri2 ] ); # empty, they are equal popn my @newarray = @array->popn($n); Pops $n values from the @array. If $n is greater than the length of @array, it will return the whole @array. If $n is 0, it will return an empty array. A negative $n or non-integer is an error. my @array = (1, 2, 3, 4, 5); my @newarray = @array->popn(3); # (3, 4, 5) shiftn my @newarray = @array->shiftn($n); Works like popn, but it shifts off the front of the array instead of popping off the end. my @array = (1, 2, 3, 4, 5); my @newarray = @array->shiftn(3); # (1, 2, 3) intersect my @a = (1 .. 10); my @b = (5 .. 15); my @intersection = @a->intersect(\@b) # [ 5 .. 10 ]; Performs intersection between arrays, returning those elements that are present in all of the argument arrays simultaneously. As with "diff()", it works with any number of arrays, nested data structures of arbitrary depth, and handles overloaded objects graciously. ltrim rtrim trim my @trimmed = @list->trim; my @trimmed = @list->trim($character_set); Trim whitespace from each element of an array. Each works just like their scalar counterpart. my @trimmed = [ ' foo', 'bar ' ]->ltrim; # [ 'foo', 'bar ' ] my @trimmed = [ ' foo', 'bar ' ]->rtrim; # [ ' foo', 'bar' ] my @trimmed = [ ' foo', 'bar ' ]->trim; # [ 'foo', 'bar' ] As with the scalar trim() methods, they all take an optional $character_set which will determine what characters should be trimmed. my @trimmed = ['-> foo <-', '-> bar <-']->trim('-><'); # [' foo ', ' bar '] Hash Autoboxing All of the methods provided by "Hash Methods" in autobox::Core are available from perl5i. In addition... each Iterate through each key/value pair in a hash using a callback. my %things = ( foo => 23, bar => 42 ); %things->each( func($k, $v) { say "Key: $k, Value: $v" }); Unlike the "each" function, individual calls to each are guaranteed to iterate through the entirety of the hash. flip Exchanges values for keys in a hash. my %things = ( foo => 1, bar => 2, baz => 5 ); my %flipped = %things->flip; # { 1 => foo, 2 => bar, 5 => baz } If there is more than one occurence of a certain value, any one of the keys may end up as the value. This is because of the random ordering of hash keys. # Could be { 1 => foo }, { 1 => bar }, or { 1 => baz } { foo => 1, bar => 1, baz => 1 }->flip; Because hash references cannot usefully be keys, it will not work on nested hashes. { foo => [ 'bar', 'baz' ] }->flip; # dies merge Recursively merge two or more hashes together using Hash::Merge::Simple. my $a = { a => 1 }; my $b = { b => 2, c => 3 }; $a->merge($b); # { a => 1, b => 2, c => 3 } For conflicting keys, rightmost precedence is used: my $a = { a => 1 }; my $b = { a => 100, b => 2}; $a->merge($b); # { a => 100, b => 2 } $b->merge($a); # { a => 1, b => 2 } It also works with nested hashes, although it won't attempt to merge array references or objects. For more information, look at the Hash::Merge::Simple docs. diff my %staff = ( bob => 42, martha => 35, timmy => 23 ); my %promoted = ( timmy => 23 ); %staff->diff(\%promoted); # { bob => 42, martha => 35 } Returns the key/value pairs present in the first hash that are not present in the subsequent hash arguments. Otherwise works as "@array->diff". intersect %staff->intersect(\%promoted); # { timmy => 23 } Returns the key/value pairs that are present simultaneously in all the hash arguments. Otherwise works as "@array->intersect". Code autoboxing signature my $sig = $code->signature; You can query the signature of any code reference defined with "func" or "method". See "Signature Introspection" for details. If $code has a signature, returns an object representing $code's signature. See perl5i::Signature for details. Otherwise it returns nothing. caller Perl6::Caller causes "caller" to return an object in scalar context. die "die" now always returns an exit code of 255 instead of trying to use $! or $? which makes the exit code unpredictable. If you want to exit with a message and a special exit code, use "warn" then "exit". list "list" will force list context similar to how scalar will force scalar context. utf8::all perl5i turns on utf8::all which turns on all the Unicode features of Perl it can. Here is the current list, more may be turned on later. Bare strings in your source code are now UTF8. This means UTF8 variable and method names, strings and regexes. my $message = "انا لا اتكلم العربيه"; my $τάδε = "It's all Greek to me!"; sub fünkßhüñ { ... } Strings will be treated as a set of characters rather than a set of bytes. For example, "length" will return the number of characters, not the number of bytes. length("perl5i is MËTÁŁ"); # 15, not 18 @ARGV will be read as UTF8. STDOUT, STDIN, STDERR and all newly opened filehandles will have UTF8 encoding turned on. Consequently, if you want to output raw bytes to a file, such as outputting an image, you must set "binmode $fh". capture my($stdout, $stderr) = capture { ... } %options; my $stdout = capture { ... } %options; "capture()" lets you capture all output to "STDOUT" and "STDERR" in any block of code. # $out = "Hello" # $err = "Bye" my($out, $err) = capture { print "Hello"; print STDERR "Bye"; }; If called in scalar context, it will only return "STDOUT" and silence "STDERR". # $out = "Hello" my $out = capture { print "Hello"; warn "oh god"; }; "capture" takes some options. tee tee will cause output to be captured yet still printed. my $out = capture { print "Hi" } tee => 1; merge merge will merge "STDOUT" and "STDERR" into one variable. # $out = "HiBye" my $out = capture { print "Hi"; print STDERR "Bye"; } merge => 1; Carp "croak" and "carp" from Carp are always available. The Carp message will always format consistently, smoothing over the backwards incompatible change in Carp 1.25. Child Child provides the "child" function which is a better way to do forking. "child" creates and starts a child process, and returns an Child::Link::Proc object which is a better interface for managing the child process. The only required argument is a codeblock, which is called in the new process. exit() is automatically called for you after the codeblock returns. my $proc = child { my $parent = shift; ... }; You can also request a pipe for IPC: my $proc = child { my $parent = shift; $parent->say("Message"); my $reply = $parent->read(); ... } pipe => 1; my $message = $proc->read(); $proc->say("reply"); See Child for more information. English English gives English names to the punctuation variables; for instance, "<$@"> is also "<$EVAL_ERROR">. See perlvar for details. It does not load the regex variables which affect performance. $PREMATCH, $MATCH, and $POSTMATCH will not exist. See the "p" modifier in perlre for a better alternative. Modern::Perl Modern::Perl turns on strict and warnings, enables all the 5.10 features like "given/when", "say" and "state", and enables C3 method resolution order. CLASS Provides "CLASS" and $CLASS alternatives to "__PACKAGE__". File::chdir File::chdir gives you $CWD representing the current working directory and it's assignable to "chdir". You can also localize it to safely chdir inside a scope. File::stat File::stat causes "stat" to return an object in scalar context. DateTime "time", "localtime", and "gmtime" are replaced with DateTime objects. They will all act like the core functions. # Sat Jan 10 13:37:04 2004 say scalar gmtime(2**30); # 2004 say gmtime(2**30)->year; # 2009 (when this was written) say time->year; Time::y2038 "gmtime()" and "localtime()" will now safely work with dates beyond the year 2038 and before 1901. The exact range is not defined, but we guarantee at least up to 2**47 and back to year 1. IO::Handle Turns filehandles into objects so you can call methods on them. The biggest one is "autoflush" rather than mucking around with $| and "select". $fh->autoflush(1); autodie autodie causes system and file calls which can fail ("open", "system", and "chdir", for example) to die when they fail. This means you don't have to put "or die" at the end of every system call, but you do have to wrap it in an "eval" block if you want to trap the failure. autodie's default error messages are pretty smart. All of autodie will be turned on. autovivification autovivification fixes the bug/feature where this: $hash = {}; $hash->{key1}{key2}; Results in "$hash->{key1}" coming into existence. That will no longer happen. No indirect object syntax perl5i turns indirect object syntax, ie. "new $obj", into a compile time error. Indirect object syntax is largely unnecessary and removing it avoids a number of ambiguous cases where Perl will mistakenly try to turn a function call into an indirect method call. See indirect for details. want "want()" generalizes the mechanism of the wantarray function, allowing a function to determine the context it's being called in. Want distinguishes not just scalar v. array context, but void, lvalue, rvalue, boolean, reference context, and more. See perldoc Want for full details. Try::Tiny Try::Tiny gives support for try/catch blocks as an alternative to "eval BLOCK". This allows correct error handling with proper localization of $@ and a nice syntax layer: # handle errors with a catch handler try { die "foo"; } catch { warn "caught error: $_"; }; # just silence errors try { die "foo"; }; See perldoc Try::Tiny for details. true You no longer have to put a true value at the end of a module which uses perl5i. Better load errors Most of us have learned the meaning of the dreaded "Can't locate Foo.pm in @INC". Admittedly though, it's not the most helpful of the error messages. In perl5i we provide a much friendlier error message. Example: Can't locate My/Module.pm in your Perl library. You may need to install it from CPAN or another repository. Your library paths are: Indented list of paths, 1 per line... Turning off features use perl5i::2 -skip => \@features_to_skip; While perl5i is intended as a curated collection of modules, its possible you might not want certain features. Features can be turned off in your scope by using "-skip". For example, this will skip loading Try::Tiny. use perl5i::latest -skip => [qw(Try::Tiny)]; Why would you do this? You might want to use a different try/catch module such as TryCatch which provides its own "try" and "catch". The feature strings are: "autobox", "autodie", "autovivification", "capture", "Carp::Fix::1_25", "Child", "CLASS", "die", "English", "File::chdir", "indirect", "list", "Meta", "Modern::Perl", "Perl6::Caller", "Signatures", "stat", "time", "true", "Try::Tiny", "utf8::all", "Want". Command line program There is a perl5i command line program installed with perl5i (Windows users get perl5i.bat). This is handy for writing one liners. perl5i -e 'gmtime->year->say' And you can use it on the "#!" line. #!/usr/bin/perl5i gmtime->year->say; If you write a one-liner without using this program, saying "-Mperl5i" means "-Mperl5i::latest". Please see "Using perl5i" and "VERSIONING" for details. BUGS Some parts are not lexical. Some parts are package scoped. If you're going to use two versions of perl5i together, we do not currently recommend having them in the same package. See for a complete list. Please report bugs at . VERSIONING perl5i follows the Semantic Versioning policy, . In short... Versions will be of the form X.Y.Z. 0.Y.Z may change anything at any time. Incrementing X (ie. 1.2.3 -> 2.0.0) indicates a backwards incompatible change. Incrementing Y (ie. 1.2.3 -> 1.3.0) indicates a new feature. Incrementing Z (ie. 1.2.3 -> 1.2.4) indicates a bug fix or other internal change. NOTES Inspired by chromatic's Modern::Perl and in particular http://www.modernperlbooks.com/mt/2009/04/ugly-perl-a-lesson-in-the-impo rtance-of-language-design.html. I totally didn't come up with the "Perl 5 + i" joke. I think it was Damian Conway. THANKS Thanks to our contributors: Chas Owens, Darian Patrick, rjbs, chromatic, Ben Hengst, Bruno Vecchi and anyone else I've forgotten. Thanks to Flavian and Matt Trout for their signature and Devel::Declare work. Thanks to all the CPAN authors upon whom this builds. LICENSE Copyright 2009-2010, Michael G Schwern This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See SEE ALSO Repository: Issues/Bugs: IRC: on the #perl5i channel Wiki: Twitter: Frequently Asked Questions about perl5i: perl5ifaq Some modules with similar purposes include: Modern::Perl, Common::Sense For a complete object declaration system, see Moose and MooseX::Declare. perl5i-v2.12.0/SIGNATURE000640000765000024 2635012155475024 14571 0ustar00schwernstaff000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.70. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 b38d844144d8fd1d7273736c48f01106df558137 .perlcriticrc SHA1 f723872651f0cd52a4aca957af3536f931667340 .perltidyrc SHA1 86572fe1b84229cb9636e7096396ef1455e70508 Build.PL SHA1 aac009f62aa132f5788a2ce54830ab57a0517fee Changes SHA1 e421537a09310e0e3b3fc430b50d85a0e9d42465 INSTALL.SKIP SHA1 689fcca99aa9bc088b979ef36eddc0af4f28bbdf LICENSE SHA1 bd21873647ec772b404aef87fc9d1f6e05774ac8 MANIFEST SHA1 8f1a2d68635cde4947fe17c475adc9eedc882682 MANIFEST.SKIP SHA1 3dc1c336e048ba4dbe559259e69416ebf4093ad5 META.json SHA1 b9966146b76db5398550a534842d8d2ba2211444 META.yml SHA1 f5b7718ad133f036cf62e6ba93bfb6e61572a4c0 PATCHING SHA1 69fda6d65d4fbd09d5064aa30e0b8bb7aba3e06f README SHA1 8c3d41e535df82cfc3e27bdd8f3c962d93a975b7 bin/perl5i.bat.PL SHA1 669e8e04934906fd5dc114f891cda03d3008a4df bin/perl5i.c.PL SHA1 c2f623ee631640aebd3c9ee304c292c1cde9e115 bin/perl5i.plx SHA1 bdd9329cc7d5bf0430ea3b9908b2dd271339de60 inc/MyBuild.pm SHA1 0e0e9ead1d17521db890d5aaf22600b653c69013 lib/perl5i.pm SHA1 a857a2462c6656ad26263ab74df68f4c532bb8db lib/perl5i/0.pm SHA1 afe00b11fd3ee704096fc166d95a50805c0b0d2a lib/perl5i/0/ARRAY.pm SHA1 f7d5bde84eae968c048101befa515cf7dc5131b1 lib/perl5i/0/DEFAULT.pm SHA1 ae9fcfc99143b891ecaca6bb51298fbb38732c88 lib/perl5i/0/DateTime.pm SHA1 2fd0a62a5f391e2f22ec3920ebfb37f07bf375f5 lib/perl5i/0/HASH.pm SHA1 f5493e77838faf72ae4b923d4780f4ef387382f4 lib/perl5i/0/Meta.pm SHA1 81158b8ef228eed67fbc9b707ac723dcbc5b1141 lib/perl5i/0/Meta/Class.pm SHA1 6a6de143060a9998291f49acb45b82324b45b344 lib/perl5i/0/Meta/Instance.pm SHA1 3f5f4e9d4f1e77cdd65c870e3f5197067f8c68e2 lib/perl5i/0/SCALAR.pm SHA1 7f67ea42ab131ed2bcd3fc5c72d78de04e8fdf50 lib/perl5i/1.pm SHA1 c7e96fb060db4a5e58c2569bdb7aa0a837234e5e lib/perl5i/1/ARRAY.pm SHA1 f1480821bef5aef519bebda72cc164fff222c2da lib/perl5i/1/CODE.pm SHA1 b01b8ef02a2155f272735035d7bdabb57a16ae44 lib/perl5i/1/DateTime.pm SHA1 5810cd9c983ea722fc0969d2344f04bbbc377eca lib/perl5i/1/HASH.pm SHA1 198cda2277028cc601ec3878e3b8bb3c9dd38502 lib/perl5i/1/Meta.pm SHA1 8f90cc918a83a85b7454d221d1e6309b0de01c95 lib/perl5i/1/Meta/Class.pm SHA1 a8cef8eb86f6803a220bfe7f0c98b610264cb85b lib/perl5i/1/Meta/Instance.pm SHA1 04ffa5ad0e8870265d4447cbfec4a458ae1969d1 lib/perl5i/1/SCALAR.pm SHA1 2a1d096958fdcef671e901c1c38c4646d533bbc8 lib/perl5i/1/UNIVERSAL.pm SHA1 3c5e3b33a81e92de285b515f4f89b76912ecc456 lib/perl5i/1/autobox.pm SHA1 3245252b07624540e89beeb9304bb380e35d3526 lib/perl5i/2.pm SHA1 ea81f21f7c6d86b3b0884e87d0f20b47c545e23a lib/perl5i/2/ARRAY.pm SHA1 67ab683759eecfea3135e1656e4a77524e840922 lib/perl5i/2/CODE.pm SHA1 cb64a5676d1cc89ed57551ccdcc6ddd603704c54 lib/perl5i/2/DateTime.pm SHA1 bd8ea56e6d5993491a1e3d6ab607e079f14755aa lib/perl5i/2/HASH.pm SHA1 4a298d9f07ca25b521a022369910edffa66c7298 lib/perl5i/2/Meta.pm SHA1 64158daa4a63c895d01873352e49279592200bb9 lib/perl5i/2/Meta/Class.pm SHA1 e0a9674edc21357a935c5376a1a062095f2bb541 lib/perl5i/2/Meta/Instance.pm SHA1 e1a52dcc88d305b13efb7409ebb57a3928f33e44 lib/perl5i/2/RequireMessage.pm SHA1 66ce4d7ede1ad5b31991e9351d785e926af0683c lib/perl5i/2/SCALAR.pm SHA1 5999ee79b914aef544079efa7c9846c637a0b63f lib/perl5i/2/Signature.pm SHA1 8c4f81a68b490e92ef63812b9a969dcd111588e3 lib/perl5i/2/Signature/Function/None.pm SHA1 d7d5cbbcbb596f5a20136629fee00a17e577583f lib/perl5i/2/Signature/Method/None.pm SHA1 25e2d5f592ab2e417af01f5b999b47fa60cfde9d lib/perl5i/2/Signature/None.pm SHA1 5e44c93935e25348114244851c55d61bf9d7be26 lib/perl5i/2/Signature/Real.pm SHA1 f4f74663f9e14793221deceefd31233201f0a7e0 lib/perl5i/2/Signatures.pm SHA1 3f157c1f0248ec9b3db89ec2990fd20492cf7c9c lib/perl5i/2/UNIVERSAL.pm SHA1 dd478e14034c6e080729715a4234adab51b5af10 lib/perl5i/2/autobox.pm SHA1 851dbfcda54cb605ee27474cfe9705d2e96d6138 lib/perl5i/2/equal.pm SHA1 38f282ad1b455787b563769e34a5e387d2b78b8e lib/perl5i/Meta.pod SHA1 e9bede08156b12885b3be8a9faf4756941e20d46 lib/perl5i/Signature.pod SHA1 5caa814d85f199ddf2a4ec186b2ac3aa60376190 lib/perl5i/VERSION.pm SHA1 0d0266a715f8b5e5019c32e2fbe1c16dfa09b78e lib/perl5i/cmd.pm SHA1 7eee47edc7738c801e3ab8ea9557b991fe0a734d lib/perl5i/latest.pm SHA1 db5f743c78f8f3047117630ceb454d8a9665ac7a lib/perl5ifaq.pod SHA1 8ea1ad62f475267b2dd9db33c12418b0b4ecefcd local-lib-rc SHA1 990e85c3266a7d9127763929b71f51c332275fcb t/ARGV.t SHA1 64965893a50c514d0f6478705aa846caefa89089 t/ARGV_twice.t SHA1 59f2fb408a2657bde427dfb3da2611634824cfff t/CLASS.t SHA1 047fbda57d28d379a9227726275d5d091c5e96e1 t/Child.t SHA1 b82195fb62380fcd1af36b12287bf274919e8b73 t/English.t SHA1 5cc638a216db348a23c7e198d41e0ac551e72d50 t/File-stat.t SHA1 1e11faedc1834ba90fb921b9fd859f8b99afbf5d t/List-MoreUtils/all.t SHA1 db7a237ffc50c71443a31b5cc61ba6cdce4a311e t/List-MoreUtils/any.t SHA1 fc59b1e3f2417133bb5626a3bd5be55fd16b9f56 t/List-MoreUtils/false.t SHA1 a5f6cd80353ac5de9e77d8d3b97ca3bc437d0f45 t/List-MoreUtils/mesh.t SHA1 0d05542814a801c535e196e8bdfd09b92809f7e9 t/List-MoreUtils/minmax.t SHA1 acddb49865c5f7e5bc0050f0b61941b7bad5e3ee t/List-MoreUtils/none.t SHA1 59d66e49836ec3489ad843d4604092be014d5520 t/List-MoreUtils/true.t SHA1 08c28ff3ca82dcbe936528aba39f8713e7e94eaf t/List-MoreUtils/uniq.t SHA1 dd9768d3e498f6ace0300dc1bfb6bae677a6fa07 t/List-Util/first.t SHA1 1d0b05499eec4710f3afb51ef36c5a0f930a63b6 t/List-Util/max.t SHA1 194364a7535687231943e040f11b8771102fbd9d t/List-Util/maxstr.t SHA1 afa264ab8eb08efba9637eb4ed9c39099b6e7c30 t/List-Util/min.t SHA1 dab896c18edacfdf21c290f03740c0b607a6baa5 t/List-Util/minstr.t SHA1 1f089b6178fb2d2f861733c9b8b172ffc57ec15c t/List-Util/reduce.t SHA1 5843e14fff6dd24127893f1dbc9837111dec9778 t/List-Util/shuffle.t SHA1 8014885ac0c2db52bccef7574a0fcf7511f43253 t/List-Util/sum.t SHA1 020ee1729431efa3c096c094e49548a3bd2de5ae t/Meta/ISA.t SHA1 284b74130f74be0fd0c22e40144d97d5f85bf10b t/Meta/checksum.t SHA1 3733690568feed4a6d37611f0412695f9960ad87 t/Meta/class.t SHA1 bdf2f1e4ee6b75ceca36ccf918c340f4188dda42 t/Meta/id.t SHA1 93f9d2f93f56c6514ce3209e302a434ca1b2ba1c t/Meta/is-equal.t SHA1 3964cb3f4481d058f667d5d0a2558be29ba150af t/Meta/linear_isa.t SHA1 0c0426d4a7fe1e7c1194957f6af2f91ca310c86e t/Meta/methods.t SHA1 2df951eafd89d997df5a5405350b245d0e349bf8 t/Meta/reftype.t SHA1 1c9fcaba3419e734ba995f7a3cfe961036a05fa0 t/Meta/super.t SHA1 96a0fc55f0e80a23aeb76faa7c0aeca7088da321 t/Meta/symbol_table.t SHA1 004a351b81308007a5db17ded798a0404dd0e0f1 t/Want.t SHA1 de6cd53c95afb4e59c2303ac790d2c4d8c509db0 t/alias.t SHA1 f1968a580232647f409e4bae13effa9fe5c1e0b7 t/as_hash.t SHA1 81fbaa24db062d0a8c5195f0ab9b3a6f8a8d546f t/autobox.t SHA1 91b5115909d964cbb9950d8577e1bb0d3ea38a56 t/autodie.t SHA1 b20d9c7a317f6b85383ed60201d2407d3f571fb8 t/autovivification.t SHA1 dda81cd929af7ddcc21643295025a053ace3951e t/caller.t SHA1 b04e6a63989d93d6e368ca21fe8b186110a91a01 t/can.t SHA1 de1a2b1ce4678806fe8ecd0bad606bf416cdc78a t/capture.t SHA1 3b80e6c918fa0f8008f9db0e5e124e2620c226c4 t/carp.t SHA1 542a5f0a69b3ef4ff100631f1073106e1b6cc5ab t/center.t SHA1 3e2c1702a6bec409d2fe117863142f4c500a0ad4 t/chdir.t SHA1 71fbd7e1b0d5f135d14d1c379bdb8ffbd782a610 t/command_line_wrapper.t SHA1 aa8a48ce799950b1b0a06772ac01993debf58621 t/commify.t SHA1 543d149d3fe5789f115f3e3f4ad736b3b93845cd t/datetime.t SHA1 0fbeca21adb225c48f08e2fb562006f609c61998 t/die.t SHA1 bb31216f9ed908452d713de1ef9620ae3446606d t/diff.t SHA1 8945533e9203e2dd48262270d1f926d25b998b55 t/dump/array.t SHA1 45275d577aa3fa77392d66440875caba862c75f5 t/dump/code.t SHA1 7b26c1ad6679d5c1e813b5201f928f83d5b36f3c t/dump/formats.t SHA1 1b78ec6671c3fc4f9f8e72e1cae1331105df8ea3 t/dump/hash.t SHA1 1acc61626ef4dec5b71d456a3e6887c67f7f9bff t/dump/obj.t SHA1 84d68af657bf0beca28abbb42ec6a6a278b3f449 t/dump/scalar.t SHA1 866ef9fd1ff9f7becca1ac7b094afa4b5515ed6d t/each.t SHA1 88e95b3c878f0b0f97ecb23e46efe3d7657da4f3 t/equal.t SHA1 e49ca6cb537f62dd0766da70e94a3e7e18e589b7 t/everything_is_an_object.t SHA1 23bc0d1617548ece708190a5b688f295a8c1a144 t/flip.t SHA1 c56c77313ebd1811d36bea2ceac1de332510ca19 t/foreach.t SHA1 84de180598dd1e41e6b3a1fddb495f8cb39ba34d t/github164.t SHA1 07982dae8573e4c90d2171f07dfbde49fe1d62ec t/grep.t SHA1 d2a5ebccce4b04e6e5da2e75fb6fed68aad0f134 t/hash-diff.t SHA1 c6e050b2ba9f91f51fec6586c8c104c282077323 t/hash-intersect.t SHA1 231c27d4c444e6bee92fbce66885433b25181cad t/hash-merge.t SHA1 b53507b0a3dae082bccef4aa1bca0b7028e6ba81 t/intersect.t SHA1 730463409da99a2878d6c6e2e0b69b4d3b65b48e t/io-handle.t SHA1 69e9ee65626dd4abcbb4f0f59d537a4ef5cd0e24 t/is_module_name.t SHA1 a979f00b3fde16aef7c835afb377b54ef424366f t/lexical.t SHA1 6879f789bab69449d1137709ce4bb0f88ea8a290 t/lib/Test/perl5i.pm SHA1 d81a5833448a1fe358691f19d527c42433440e6b t/lib/ThisIsTrue.pm SHA1 6473a2e78846f710a3aaf268a6d41aa8af71e9c7 t/list-trim.t SHA1 38d25aaee795c4137932bf3e711c0460ebf0a9ce t/list.t SHA1 d72a3c5210b079dc8c79c963f72b312d44934bc0 t/load_together.t SHA1 77a071110a2a1d7d637747039a2aa4ccbf9c9e2a t/map.t SHA1 f0ee744762d3e52548e9f657608e617eccf38ea3 t/method_leaking.t SHA1 f3c7d03f6caeb7a2d5ad361abc0ec09dcb843be7 t/modern_perl.t SHA1 f1b731cee16d4c8fb8d924ef396e441052d2f92b t/module2path.t SHA1 ab901ec08963d28100d6cea98826996d69afc621 t/no_indirect.t SHA1 854d339355b7fbc0d4b60e8e487e9f7dd5ff5840 t/number.t SHA1 8b85b0a5286c3552715056eedfa4e83a55d88ba4 t/perl5i.t SHA1 af1cdc368b18ab992883ae36fe7c77b20d2d88ea t/pick.t SHA1 71abd31bd6f36a93499005fd69c9cd011ea1371a t/popn.t SHA1 4a82e132de9a3106c465838727376025ec71c850 t/require.t SHA1 0a243f1cd437827c2d693ecde83eeba90be729b6 t/require_message.t SHA1 2e1ebff1f7afdf5f31275abf1e2ba827bbf7c7ee t/say.t SHA1 9f60e6a179bc75dbda34688d597f42b75280c7f5 t/scalar.t SHA1 8170f80704483c9c9d61fd7d048b181457cfc79e t/shiftn.t SHA1 378036382ffe51eabc5a716336c5da770edb9e35 t/signature.t SHA1 d4b3c6c027ce4c9499693cef8b02701c9ed5644b t/signatures.t SHA1 50992f3d63c986f032f6eae58c6946fb1ac04f50 t/skip.t SHA1 b53366faf1234bcaeb79eed6cabccaf33444d52f t/taint.t SHA1 6f5c6d96cf7afc1be4f166cb4b938833fb03ae77 t/time_compat.t SHA1 01ee92a12246a9fa748d64d449a666bfa284e4f0 t/true.t SHA1 50494d642603c31dfd7ca367957d3b8bd1fe8bbc t/try-tiny.t SHA1 a0bcc9bfbd5f3f28ee0cadb165f7237aa145bff2 t/uniq.t SHA1 5c0615dceefa82c04e853ea0d5215cca64045201 t/utf8.t SHA1 50f73b2661272e821c9e22cb3e13088624031f58 t/version_0/00_compile.t SHA1 733e55e3fcf755dbe3d9e4d0d24036c4c02a1943 t/version_1/00_compile.t SHA1 f35b88bed7a9d65b91233a6b21a0239d07fac331 t/vs_listmoreutils.t SHA1 24924095de8d8e8761fb72525b297c875f811e62 t/wrap.t SHA1 513209d8bd9be29e5b9fafe997d626489e345c59 t/y2038.t -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.18 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJRtnoTAAoJEJxzdbWzfct36skH/RT8ixwUJcIN8vjTEbmr+AhK xV7uCHRGdB53r30YLUCRcRiCkCJPJ2W/hB9brVQpSCqOp+0vJuYxTMwe8p6f8aDS 4Qk25//sEJDq/lr6e46e1INfCGfd3ta0doikK+mMiY/jDk23pBxVZyZABHH7w25j o4N6SizvvmVk5F6rGIY2pd5eTRPP+toeGwIr013pEioJ4NTYXcnM45+7xu295S0q V+Ly0dcLDvzrbnMDyw3g3hEXvmqpjMp0ytgXmpK14gzjNbgoKajrh95VJvgR5I3r GJh0Vj3bmaEVX3fmKDknY/gJpXp3uZWobQf13Mhe/5Iw1riHEoeSjNR5bNskXYE= =dWYG -----END PGP SIGNATURE----- perl5i-v2.12.0/bin000750000765000024 012155475023 13666 5ustar00schwernstaff000000000000perl5i-v2.12.0/bin/perl5i.bat.PL000555000765000024 25412155475023 16216 0ustar00schwernstaff000000000000#!/usr/bin/perl -w my $file = shift; open my $fh, ">", $file or die "Can't open $file: $!"; printf $fh <<'END', $^X; @echo off %s -Mperl5i::cmd=perl5i.bat %%* END perl5i-v2.12.0/bin/perl5i.c.PL000444000765000024 516012155475023 15710 0ustar00schwernstaff000000000000# Write out the perl5i wrapper C program making sure it uses # the Perl its built with. use strict; use warnings; use File::Spec; my $file = shift; # Its going inside double quotes. my $perl_path = $^X; $perl_path =~ s{ ([\\"]) }{\\$1}gx; my $tempdir = File::Spec->tmpdir || "/tmp"; open my $fh, ">", $file or die $!; printf $fh <<'END', $0, $perl_path, $tempdir; /* THIS FILE IS GENERATED BY %s * Any changes here will be wiped out. Edit it there instead. */ #define DEBUG 0 #include #include #include #include /* * Meant to mimic the shell command * exec perl -Mperl5i::latest "$@" * * This is a C program so it works in a #! line. */ int main (int argc, char* argv[]) { int i; int j; const char* perl_cmd = "%s"; char* perl_args[argc+1]; char* dash_m = (char *)malloc(sizeof(char) * (strlen(argv[0]) + 20)); char* program; int saw_dash_e = 0; strcat(dash_m, "-Mperl5i::cmd="); strcat(dash_m, argv[0]); perl_args[0] = (char *)perl_cmd; perl_args[1] = dash_m; for( i = 1, j = 2; i < argc; i++ ) { char *dash_e = strchr(argv[i], 'e'); /* Its a one liner */ if( dash_e && strcmp(dash_e, "e") == 0 && (strchr(argv[i], '-') == argv[i]) && (strchr(argv[i], 'M') != argv[i]+1) ) { saw_dash_e = 1; /* Chop out the -e */ dash_e[0] = '\0'; /* If all that's left is a dash, ignore it */ if( strcmp(argv[i], "-") != 0 ) { perl_args[j] = argv[i]; j++; } /* Skip the next argument, its the program */ program = argv[i+1]; i++; continue; } perl_args[j] = argv[i]; j++; } /* Turn one liners into real programs to work around a Devel::Declare bug */ if( saw_dash_e ) { char tempfile[] = "%s/perl5i.XXXXXX"; int fd = mkstemp(tempfile); if( fd == -1 ) { perror("Could not open temporary file 'tempfile'"); exit(1); } FILE *fh = fdopen(fd, "w"); fprintf( fh, "$0 = '-e';\n" ); fprintf( fh, "#line 1 \"-e\"\n" ); fprintf( fh, "%%s", program ); fclose(fh); perl_args[j++] = tempfile; } /* Argument array must be terminated by a null */ perl_args[j] = (char *)NULL; #if DEBUG for( i = 0; i <= j; i++ ) { printf("perl_args[%%d]: %%s\n", i, perl_args[i]); } if( saw_dash_e ) printf("program: %%s\n", program); #endif return execv( perl_cmd, perl_args ); } END perl5i-v2.12.0/bin/perl5i.plx000555000765000024 6612155475023 15722 0ustar00schwernstaff000000000000#!/usr/bin/perl exec $^X, "-Mperl5i::cmd=$0", @ARGV; perl5i-v2.12.0/inc000750000765000024 012155475023 13667 5ustar00schwernstaff000000000000perl5i-v2.12.0/inc/MyBuild.pm000555000765000024 541112155475023 15740 0ustar00schwernstaff000000000000package MyBuild; use 5.010; use base 'Module::Build'; # Override default 'code' action # to allow compilation of perl5i.c sub ACTION_code { my $self = shift; # This has to be run first so the PL files are run to generate # the C code for us to compile. $self->process_PL_files; if ( $self->is_windowsish ) { # Writing a C wrapper is too hard on Windows # Don't need it as there's no #! anyway # Just do a bat file $self->script_files("bin/perl5i.bat"); } elsif ( $self->have_c_compiler() ) { my $b = $self->cbuilder(); my $obj_file = $b->compile( source => 'bin/perl5i.c', ); my $exe_file = $b->link_executable(objects => $obj_file); # script_files is set here as the resulting compiled # executable name varies based on operating system $self->script_files($exe_file); # Cleanup files from compilation $self->add_to_cleanup($obj_file, $exe_file); } else { # No C compiler, Unix style operating system. # Just use the Perl wrapper. File::Copy::copy("bin/perl5i.plx", "bin/perl5i"); $self->script_files("bin/perl5i"); $self->add_to_cleanup("bin/perl5i"); } return $self->SUPER::ACTION_code; } # Run perltidy over all the Perl code # Borrowed from Test::Harness sub ACTION_tidy { my $self = shift; my %found_files = map { %$_ } $self->find_pm_files, $self->_find_file_by_type( 'pm', 't' ), $self->_find_file_by_type( 'pm', 'inc' ), $self->_find_file_by_type( 't', 't' ), $self->_find_file_by_type( 'PL', '.' ); my @files = ( keys %found_files, map { $self->localize_file_path($_) } @extra ); print "Running perltidy on @{[ scalar @files ]} files...\n"; for my $file ( sort { $a cmp $b } @files ) { print " $file\n"; system( 'perltidy', '-b', $file ); unlink("$file.bak") if $? == 0; } } sub ACTION_critic { my $self = shift; my @files = keys %{ $self->find_pm_files }; print "Running perlcritic on @{[ scalar @files ]} files...\n"; system( "perlcritic", @files ); } # Check if the built in local/gmtime work for a reasonable set of # time. Some systems fail at 2**47 or beyond, and a lot fail at year # 0, so those are good boundaries. # This allows us to avoid depending on Time::y2038 which is a bit # unreliable. sub needs_y2038 { my $self = shift; state $limits = { # time year 2**47-1 => 4461763, -62135510400 => 1, }; for my $time (keys %$limits) { my $year = $limits->{$time}; return 1 if (gmtime($time))[5] + 1900 != $year; return 1 if (localtime($time))[5] + 1900 != $year; } return 0; } 1; perl5i-v2.12.0/lib000750000765000024 012155475023 13664 5ustar00schwernstaff000000000000perl5i-v2.12.0/lib/perl5i.pm000444000765000024 7725312155475023 15622 0ustar00schwernstaff000000000000package perl5i; ###################################### # The real code is in perl5i::2 # # Please patch that # ###################################### use strict; use parent 'perl5i::latest'; use perl5i::VERSION; our $VERSION = perl5i::VERSION->VERSION; my $Latest = perl5i::VERSION->latest; sub import { if ($0 eq '-e') { goto &perl5i::latest::import; } else { require Carp::Fix::1_25; Carp::Fix::1_25::croak(<) or make a fork (forking on github is like a branch you control) and implement it yourself. =head1 Using perl5i Because perl5i I to be incompatible in the future, you do not simply C. You must declare which major version of perl5i you are using. You do this like so: # Use perl5i major version 2 use perl5i::2; Thus the code you write with, for example, C will always remain compatible even as perl5i moves on. If you want to be daring, you can C to get the latest version. This will automatically happen if the program is C<-e>. This lets you do slightly less typing for one-liners like C If you want your module to depend on perl5i, you should depend on the versioned class. For example, depend on C and not C. See L for more information about perl5i's versioning scheme. =head1 What it does perl5i enables each of these modules and adds/changes these functions. We'll provide a brief description here, but you should look at each of their documentation for full details. =head2 The Meta Object Every object (and everything is an object) now has a meta object associated with it. Using the meta object you can ask things about the object which were previously over complicated. For example... # the object's class my $class = $obj->mo->class; # its parent classes my @isa = $obj->mo->isa; # the complete inheritance hierarchy my @complete_isa = $obj->mo->linear_isa; # the reference type of the object my $reftype = $obj->mo->reftype; A meta object is used to avoid polluting the global method space. C was chosen to avoid clashing with Moose's meta object. See L for complete details. =head2 Subroutine and Method Signatures perl5i makes it easier to declare what parameters a subroutine takes. func hello($place) { say "Hello, $place!\n"; } method get($key) { return $self->{$key}; } method new($class: %args) { return bless \%args, $class; } C and C define subroutines as C does, with some extra conveniences. The signature syntax is currently very simple. The content will be assigned from @_. This: func add($this, $that) { return $this + $that; } is equivalent to: sub add { my($this, $that) = @_; return $this + $that; } C defines a method. This is the same as a subroutine, but the first argument, the I, will be removed and made into C<$self>. method get($key) { return $self->{$key}; } sub get { my $self = shift; my($key) = @_; return $self->{$key}; } Methods have a special bit of syntax. If the first item in the siganture is C<$var:> it will change the variable used to store the invocant. method new($class: %args) { return bless \%args, $class; } is equivalent to: sub new { my $class = shift; my %args = @_; return bless \%args, $class; } Anonymous functions and methods work, too. my $code = func($message) { say $message }; Guarantees include: @_ will not be modified except by removing the invocant Future versions of perl5i will add to the signature syntax and capabilities. Planned expansions include: Signature validation Signature documentation Named parameters Required parameters Read only parameters Aliased parameters Anonymous method and function declaration Variable method and function names Parameter traits Traditional prototypes See L for more details about future expansions. The equivalencies above should only be taken for illustrative purposes, they are not guaranteed to be literally equivalent. Note that while all parameters are optional by default, the number of parameters will eventually be enforced. For example, right now this will work: func add($this, $that) { return $this + $that } say add(1,2,3); # says 3 The extra argument is ignored. In future versions of perl5i this will be a runtime error. =head3 Signature Introspection The signature of a subroutine defined with C or C can be queried by calling the C method on the code reference. func hello($greeting, $place) { say "$greeting, $place" } my $code = \&hello; say $code->signature->num_positional_params; # prints 2 Functions defined with C will not have a signature. See L for more details. =head2 Autoboxing L allows methods to be defined for and called on most unblessed variables. This means you can call methods on ordinary strings, lists and hashes! It also means perl5i can add a lot of functionality without polluting the global namespace. L wraps a lot of Perl's built in functions so they can be called as methods on unblessed variables. C<< @a->pop >> for example. =head3 alias $scalar_reference->alias( @identifiers ); @alias->alias( @identifiers ); %hash->alias( @identifiers ); (\&code)->alias( @identifiers ); Aliases a variable to a new global name. my $code = sub { 42 }; $code->alias( "foo" ); say foo(); # prints 42 It will work on everything except scalar references. our %stuff; %other_hash->alias( "stuff" ); # %stuff now aliased to %other_hash It is not a copy, changes to one will change the other. my %things = (foo => 23); our %stuff; %things->alias( "stuff" ); # alias %things to %stuff $stuff{foo} = 42; # change %stuff say $things{foo}; # and it will show up in %things Multiple @identifiers will be joined with '::' and used as the fully qualified name for the alias. my $class = "Some::Class"; my $name = "foo"; sub { 99 }->alias( $class, $name ); say Some::Class->foo; # prints 99 If there is just one @identifier and it has no "::" in it, the current caller will be prepended. C<< $thing->alias("name") >> is shorthand for C<< $thing->alias(CLASS, "name") >> Due to limitations in autobox, non-reference scalars cannot be aliased. Alias a scalar ref instead. my $thing = 23; $thing->alias("foo"); # error my $thing = \23; $thing->alias("foo"); # $foo is now aliased to $thing This is basically a nicer way to say: no strict 'refs'; *{$package . '::'. $name} = $reference; =head2 Scalar Autoboxing All of the methods provided by L are available from perl5i. in addition, perl5i adds some methods of its own. =head3 center my $centered_string = $string->center($length); my $centered_string = $string->center($length, $character); Centers $string between $character. $centered_string will be of length $length. C<$character> defaults to " ". say "Hello"->center(10); # " Hello "; say "Hello"->center(10, '-'); # "---Hello--"; C will never truncate C<$string>. If $length is less than C<< $string->length >> it will just return C<$string>. say "Hello"->center(4); # "Hello"; =head3 round my $rounded_number = $number->round; Round to the nearest integer. =head3 round_up =head3 ceil my $new_number = $number->round_up; Rounds the $number towards infinity. 2.45->round_up; # 3 (-2.45)->round_up; # -2 ceil() is a synonym for round_up(). =head3 round_down =head3 floor my $new_number = $number->round_down; Rounds the $number towards negative infinity. 2.45->round_down; # 2 (-2.45)->round_down; # -3 floor() is a synonyn for round_down(). =head3 is_number $is_a_number = $thing->is_number; Returns true if $thing is a number understood by Perl. 12.34->is_number; # true "12.34"->is_number; # also true "eleven"->is_number; # false =head3 is_positive $is_positive = $thing->is_positive; Returns true if $thing is a positive number. 0 is not positive. =head3 is_negative $is_negative = $thing->is_negative; Returns true if $thing is a negative number. 0 is not negative. =head3 is_even $is_even = $thing->is_even; Returns true if $thing is an even integer. =head3 is_odd $is_odd = $thing->is_odd; Returns true if $thing is an odd integer. =head3 is_integer $is_an_integer = $thing->is_integer; Returns true if $thing is an integer. 12->is_integer; # true 12.34->is_integer; # false "eleven"->is_integer; # false =head3 is_int A synonym for is_integer =head3 is_decimal $is_a_decimal_number = $thing->is_decimal; Returns true if $thing is a decimal number. 12->is_decimal; # false 12.34->is_decimal; # true ".34"->is_decimal; # true "point five"->is_decimal; # false =head3 require my $module = $module->require; Will C the given $module. This avoids funny things like C. It accepts only module names. On failure it will throw an exception, just like C. On a success it returns the $module. This is mostly useful so that you can immediately call $module's C method to emulate a C. # like "use $module qw(foo bar);" if that worked $module->require->import(qw(foo bar)); # like "use $module;" if that worked $module->require->import; =head3 wrap my $wrapped = $string->wrap( width => $cols, separator => $sep ); Wraps $string to width $cols, breaking lines at word boundries using separator $sep. If no width is given, $cols defaults to 76. Default line separator is the newline character "\n". See L for details. =head3 ltrim =head3 rtrim =head3 trim my $trimmed = $string->trim; my $trimmed = $string->trim($character_set); Trim whitespace. ltrim() trims off the start of the string (left), rtrim() off the end (right) and trim() off both the start and end. my $string = ' testme'->ltrim; # 'testme' my $string = 'testme '->rtrim; # 'testme' my $string = ' testme '->trim; # 'testme' They all take an optional $character_set which will determine what characters should be trimmed. It follows regex character set syntax so C will trim everything from A to Z. Defaults to C<\s>, whitespace. my $string = '-> test <-'->trim('-><'); # ' test ' =head3 title_case my $name = 'joe smith'->title_case; # Joe Smith Will uppercase every word character that follows a wordbreak character. =head3 path2module my $module = $path->path2module; Given a relative $path it will return the Perl module this represents. For example, "Foo/Bar.pm"->path2module; # "Foo::Bar" It will throw an exception if given something which could not be a path to a Perl module. =head3 module2path my $path = $module->module2path; Will return the relative $path in which the Perl $module can be found. For example, "Foo::Bar"->module2path; # "Foo/Bar.pm" =head3 is_module_name my $is_valid = $string->is_module_name; Will return true if the $string is a valid module name. "Foo::Bar"->is_module_name; # true "Foo/Bar"->is_module_name; # false =head3 group_digits my $number_grouped = $number->group_digits; my $number_grouped = $number->group_digits(\%options); Turns a number like 1234567 into a string like 1,234,567 known as "digit grouping". It honors your current locale to determine the separator and grouping. This can be overridden using C<%options>. NOTE: many systems do not have their numeric locales set properly =over 4 =item separator The character used to separate groups. Defaults to "thousands_sep" in your locale or "," if your locale doesn't specify. =item decimal_point The decimal point character. Defaults to "decimal_point" in your locale or "." if your locale does not specify. =item grouping How many numbers in a group? Defaults to "grouping" in your locale or 3 if your locale doesn't specify. Note: we don't honor the full grouping locale, its a wee bit too complicated. =item currency If true, it will treat the number as currency and use the monetary locale settings. "mon_thousands_sep" instead of "thousands_sep" and "mon_grouping" instead of "grouping". =back 1234->group_digits; # 1,234 (assuming US locale) 1234->group_digits( separator => "." ); # 1.234 =head3 commify my $number_grouped = $number->commify; my $number_grouped = $number->commify(\%options); commify() is just like group_digits() but it is not locale aware. It is useful when you want a predictable result regardless of the user's locale settings. C<%options> defaults to C<< ( separator => ",", grouping => 3, decimal_point => "." ) >>. Each key will be overridden individually. 1234->commify; # 1,234 1234->commify({ separator => "." }); # 1.234 =head3 reverse my $reverse = $string->reverse; Reverses a $string. Unlike Perl's reverse(), this always reverses the string regardless of context. =head2 Array Autoboxing The methods provided by L are available from perl5i. All the functions from L and select ones from L are all available as methods on unblessed arrays and array refs: first, max, maxstr, min, minstr, minmax, shuffle, reduce, sum, any, all, none, true, false, uniq and mesh. They have all been altered to return array refs where applicable in order to allow chaining. @array->grep(sub{ $_->is_number })->sum->say; =head3 foreach @array->foreach( func($item) { ... } ); Works like the built in C, calls the code block for each element of @array passing it into the block. @array->foreach( func($item) { say $item } ); # print each item It will pass in as many elements as the code block accepts. This allows you to iterate through an array 2 at a time, or 3 or 4 or whatever. my @names = ("Joe", "Smith", "Jim", "Dandy", "Jane", "Lane"); @names->foreach( func($fname, $lname) { say "Person: $fname $lname"; }); A normal subroutine with no signature will get one at a time. If @array is not a multiple of the iteration (for example, @array has 5 elements and you ask 2 at a time) the behavior is currently undefined. =head3 as_hash my %hash = @array->as_hash; This method returns a %hash where each element of @array is a key. The values are all true. Its functionality is similar to: my %hash = map { $_ => 1 } @array; Example usage: my @array = ("a", "b", "c"); my %hash = @array->as_hash; say q[@array contains 'a'] if $hash{"a"}; =head3 pick my @rand = @array->pick($number); The pick() method returns a list of $number elements in @array. If $number is larger than the size of the list, it returns the entire list shuffled. Example usage: my @array = (1, 2, 3, 4); my @rand = @array->pick(2); =head3 pick_one my $rand = @array->pick_one; The pick_one() method returns a random element in @array. It is similar to @array->pick(1), except that it does not return a list. Example usage: my @array = (1,2,3,4); my $rand = @array->pick_one; =head3 diff Calculate the difference between two (or more) arrays: my @a = ( 1, 2, 3 ); my @b = ( 3, 4, 5 ); my @diff_a = @a->diff(\@b) # [ 1, 2 ] my @diff_b = @b->diff(\@a) # [ 4, 5 ] Diff returns all elements in array C<@a> that are not present in array C<@b>. Item order is not considered: two identical elements in both arrays will be recognized as such disregarding their index. [ qw( foo bar ) ]->diff( [ qw( bar foo ) ] ) # empty, they are equal For comparing more than two arrays: @a->diff(\@b, \@c, ... ) All comparisons are against the base array (C<@a> in this example). The result will be composed of all those elements that were present in C<@a> and in none other. It also works with nested data structures; it will traverse them depth-first to assess whether they are identical or not. For instance: [ [ 'foo ' ], { bar => 1 } ]->diff([ 'foo' ]) # [ { bar => 1 } ] In the case of overloaded objects (i.e., L, L, L, etc.), it tries its best to treat them as strings or numbers. my $uri = URI->new("http://www.perl.com"); my $uri2 = URI->new("http://www.perl.com"); [ $uri ]->diff( [ "http://www.perl.com" ] ); # empty, they are equal [ $uri ]->diff( [ $uri2 ] ); # empty, they are equal =head3 popn my @newarray = @array->popn($n); L C<$n> values from the C<@array>. If C<$n> is greater than the length of C<@array>, it will return the whole C<@array>. If C<$n> is 0, it will return an empty array. A negative C<$n> or non-integer is an error. my @array = (1, 2, 3, 4, 5); my @newarray = @array->popn(3); # (3, 4, 5) =head3 shiftn my @newarray = @array->shiftn($n); Works like L, but it L off the front of the array instead of popping off the end. my @array = (1, 2, 3, 4, 5); my @newarray = @array->shiftn(3); # (1, 2, 3) =head3 intersect my @a = (1 .. 10); my @b = (5 .. 15); my @intersection = @a->intersect(\@b) # [ 5 .. 10 ]; Performs intersection between arrays, returning those elements that are present in all of the argument arrays simultaneously. As with C, it works with any number of arrays, nested data structures of arbitrary depth, and handles overloaded objects graciously. =head3 ltrim =head3 rtrim =head3 trim my @trimmed = @list->trim; my @trimmed = @list->trim($character_set); Trim whitespace from each element of an array. Each works just like their scalar counterpart. my @trimmed = [ ' foo', 'bar ' ]->ltrim; # [ 'foo', 'bar ' ] my @trimmed = [ ' foo', 'bar ' ]->rtrim; # [ ' foo', 'bar' ] my @trimmed = [ ' foo', 'bar ' ]->trim; # [ 'foo', 'bar' ] As with the scalar trim() methods, they all take an optional $character_set which will determine what characters should be trimmed. my @trimmed = ['-> foo <-', '-> bar <-']->trim('-><'); # [' foo ', ' bar '] =head2 Hash Autoboxing All of the methods provided by L are available from perl5i. In addition... =head3 each Iterate through each key/value pair in a hash using a callback. my %things = ( foo => 23, bar => 42 ); %things->each( func($k, $v) { say "Key: $k, Value: $v" }); Unlike the C function, individual calls to each are guaranteed to iterate through the entirety of the hash. =head3 flip Exchanges values for keys in a hash. my %things = ( foo => 1, bar => 2, baz => 5 ); my %flipped = %things->flip; # { 1 => foo, 2 => bar, 5 => baz } If there is more than one occurence of a certain value, any one of the keys may end up as the value. This is because of the random ordering of hash keys. # Could be { 1 => foo }, { 1 => bar }, or { 1 => baz } { foo => 1, bar => 1, baz => 1 }->flip; Because hash references cannot usefully be keys, it will not work on nested hashes. { foo => [ 'bar', 'baz' ] }->flip; # dies =head3 merge Recursively merge two or more hashes together using L. my $a = { a => 1 }; my $b = { b => 2, c => 3 }; $a->merge($b); # { a => 1, b => 2, c => 3 } For conflicting keys, rightmost precedence is used: my $a = { a => 1 }; my $b = { a => 100, b => 2}; $a->merge($b); # { a => 100, b => 2 } $b->merge($a); # { a => 1, b => 2 } It also works with nested hashes, although it won't attempt to merge array references or objects. For more information, look at the L docs. =head3 diff my %staff = ( bob => 42, martha => 35, timmy => 23 ); my %promoted = ( timmy => 23 ); %staff->diff(\%promoted); # { bob => 42, martha => 35 } Returns the key/value pairs present in the first hash that are not present in the subsequent hash arguments. Otherwise works as C<< @array->diff >>. =head3 intersect %staff->intersect(\%promoted); # { timmy => 23 } Returns the key/value pairs that are present simultaneously in all the hash arguments. Otherwise works as C<< @array->intersect >>. =head2 Code autoboxing =head3 signature my $sig = $code->signature; You can query the signature of any code reference defined with C or C. See L for details. If C<$code> has a signature, returns an object representing C<$code>'s signature. See L for details. Otherwise it returns nothing. =head3 caller L causes C to return an object in scalar context. =head3 die C now always returns an exit code of 255 instead of trying to use C<$!> or C<$?> which makes the exit code unpredictable. If you want to exit with a message and a special exit code, use C then C. =head3 list C will force list context similar to how L will force scalar context. =head2 utf8::all perl5i turns on L which turns on all the Unicode features of Perl it can. Here is the current list, more may be turned on later. Bare strings in your source code are now UTF8. This means UTF8 variable and method names, strings and regexes. my $message = "انا لا اتكلم العربيه"; my $τάδε = "It's all Greek to me!"; sub fünkßhüñ { ... } Strings will be treated as a set of characters rather than a set of bytes. For example, C will return the number of characters, not the number of bytes. length("perl5i is MËTÁŁ"); # 15, not 18 C<@ARGV> will be read as UTF8. STDOUT, STDIN, STDERR and all newly opened filehandles will have UTF8 encoding turned on. Consequently, if you want to output raw bytes to a file, such as outputting an image, you must set C<< binmode $fh >>. =head3 capture my($stdout, $stderr) = capture { ... } %options; my $stdout = capture { ... } %options; C lets you capture all output to C and C in any block of code. # $out = "Hello" # $err = "Bye" my($out, $err) = capture { print "Hello"; print STDERR "Bye"; }; If called in scalar context, it will only return C and silence C. # $out = "Hello" my $out = capture { print "Hello"; warn "oh god"; }; C takes some options. =over 4 =item B tee will cause output to be captured yet still printed. my $out = capture { print "Hi" } tee => 1; =item B merge will merge C and C into one variable. # $out = "HiBye" my $out = capture { print "Hi"; print STDERR "Bye"; } merge => 1; =back =head2 Carp C and C from L are always available. The Carp message will always format consistently, smoothing over the backwards incompatible change in Carp 1.25. =head2 Child L provides the C function which is a better way to do forking. C creates and starts a child process, and returns an L object which is a better interface for managing the child process. The only required argument is a codeblock, which is called in the new process. exit() is automatically called for you after the codeblock returns. my $proc = child { my $parent = shift; ... }; You can also request a pipe for IPC: my $proc = child { my $parent = shift; $parent->say("Message"); my $reply = $parent->read(); ... } pipe => 1; my $message = $proc->read(); $proc->say("reply"); See L for more information. =head2 English L gives English names to the punctuation variables; for instance, C<<$@>> is also C<<$EVAL_ERROR>>. See L for details. It does B load the regex variables which affect performance. C<$PREMATCH>, C<$MATCH>, and C<$POSTMATCH> will not exist. See the C

modifier in L for a better alternative. =head2 Modern::Perl L turns on strict and warnings, enables all the 5.10 features like C, C and C, and enables C3 method resolution order. =head2 CLASS Provides C and C<$CLASS> alternatives to C<__PACKAGE__>. =head2 File::chdir L gives you C<$CWD> representing the current working directory and it's assignable to C. You can also localize it to safely chdir inside a scope. =head2 File::stat L causes C to return an object in scalar context. =head2 DateTime C