scrottie / autobox-Core

Release history of autobox-Core
http://search.cpan.org/dist/autobox-Core/
23 stars 11 forks source link

NAME autobox::Core - Provide core functions to autoboxed scalars, arrays and hashes.

SYNOPSIS use autobox::Core;

  "Hello, World\n"->uc->print;

  my @list = (1, 5, 9, 2, 0, 4, 2, 1);
  @list->sort->reverse->print;

  # works with references too!
  my $list = [1, 5, 9, 2, 0, 4, 2, 1];
  $list->sort->reverse->print;

  my %hash = (
      grass => 'green',
      apple => 'red',
      sky   => 'blue',
  );

  [10, 20, 30, 40, 50]->pop->say;
  [10, 20, 30, 40, 50]->shift->say;

  my $lala = "Lalalalala\n";
  "chomp: "->concat($lala->chomp, " ", $lala)->say;

  my $hashref = { foo => 10, bar => 20, baz => 30, qux => 40 };

  print "hash keys: ", $hashref->keys->join(' '), "\n"; # or if you prefer...
  print "hash keys: ", join ' ', $hashref->keys(), "\n"; # or
  print "hash keys: "; $hashref->keys->say;

DESCRIPTION The autobox module promotes Perl's primitive types (literals (strings and numbers), scalars, arrays and hashes) into first-class objects. However, autobox does not provide any methods for these new classes.

autobox::CORE provides a set of methods for these new classes. It
includes almost everything in perlfunc, some things from Scalar::Util
and List::Util, and some Perl 5 versions of methods taken from Perl 6.

With autobox::Core one is able to change this:

        print join(" ", reverse(split(" ", $string)));

to this:

        use autobox::Core;

        $string->split(" ")->reverse->print;

Likewise you can change this:

        my $array_ref = [qw(fish dog cat elephant bird)];

        push @$array_ref, qw(snake lizard giraffe mouse);

to this:

        use autobox::Core;
        my $array_ref = [qw(fish dog cat elephant bird)];

        $array_ref->push( qw(snake lizard giraffe mouse));

autobox::Core makes it easier to avoid parentheses pile ups and messy
dereferencing syntaxes.

autobox::Core is mostly glue. It presents existing functions with a new
interface, while adding few extra. Most of the methods read like "sub
hex { CORE::hex($_[0]) }". In addition to built-ins from perlfunc that
operate on hashes, arrays, scalars, and code references, some Perl 6-ish
things have been included, and some keywords like "foreach" are
represented too.

What's Implemented?

BUGS Yes. Report them to the author, scott@slowass.net, or post them to GitHub's bug tracker at https://github.com/scrottie/autobox-Core/issues.

The API is not yet stable -- Perl 6-ish things and local extensions are
still being renamed.

HISTORY See the Changes file.

COPYRIGHT AND LICENSE Copyright (C) 2009, 2010, 2011 by Scott Walters and various contributors listed (and unlisted) below.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.9 or, at
your option, any later version of Perl 5 you may have available.

This library 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 ALSO autobox Moose::Autobox Perl6::Contexts http://github.com/gitpan/autobox-Core IO::Any Perl 6: http://dev.perl.org/perl6/apocalypse/.

AUTHORS Scott Walters, scott@slowass.net.

Tomasz Konojacki has been assisting with maint.

Jacinta Richardson improved documentation and tidied up the interface.

Michael Schwern and the perl5i contributors for tests, code, and
feedback.

JJ contributed a "strip" method for scalars - thanks JJ!

Ricardo SIGNES contributed patches.

Thanks to Matt Spear, who contributed tests and definitions for numeric
operations.

Mitchell N Charity reported a bug and sent a fix.

Thanks to chocolateboy for autobox and for the encouragement.

Thanks to Bruno Vecchi for bug fixes and many, many new tests going into
version 0.8.

Thanks to <http://github.com/daxim> daxim/Lars DIECKOW pushing in fixes
and patches from the RT queue along with fixes to build and additional
doc examples.

Thanks to everyone else who sent fixes or suggestions -- apologies if I
failed to include you here!