Moose::Autobox(3pm)
π Moose::Autobox π
okay bestie, so this is Moose::Autobox β a User Contributed Perl Documentation page, and honestly? it's giving main character energy for your plain old Perl values. sit down, grab a strawberry π, and let's get into it.
β¨ VERSION β¨
version 0.16 β yes, she's been around a minute, and she's still iconic π
πΈ SYNOPSIS πΈ
use Moose::Autobox;
print 'Print squares from 1 to 10 : ';
print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
likeβ¦ you can literally call methods on an array. on an actual array. no cap. π₯
π¦ DESCRIPTION π¦
Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH & CODE for use with autobox. it does this using a hierarchy of roles in a manner similar to what Perl 6 might do. this module, like Class::MOP and Moose, was inspired by my work on the Perl 6 Object Space, and the 'core types' implemented there.
π A quick word about autobox
so the autobox module provides the ability for calling 'methods' on normal Perl values like Scalars, Arrays, Hashes and Code references. this gives the illusion that Perl's types are first-class objects. however, this is only an illusion, albeit a very nice one π. I created this module because autobox itself does not actually provide an implementation for the Perl types but instead only provides the 'hooks' for others to add implementation too.
π Is this for real? or just play?
several people are using this module in serious applications and it seems to be quite stable. the underlying technologies of autobox and Moose::Role are also considered stable. there is some performance hit, but as I am fond of saying, nothing in life is free. note that this hit only applies to the use of methods on native Perl values, not the mere act of loading this module in your namespace.
if you have any questions regarding this module, either email me, or stop by #moose on irc.perl.org and ask around. we're friendly, fr fr π«Ά
π§ Adding additional methods
Moose::Autobox asks autobox to use the Moose::Autobox::* namespace prefix so as to avoid stepping on the toes of other autobox modules. this means that if you want to add methods to a particular perl type (i.e. β monkeypatch), then you must do this:
sub Moose::Autobox::SCALAR::bar { 42 }
instead of this:
sub SCALAR::bar { 42 }
as you would with vanilla autobox.
bestie, do NOT skip the namespace. the Moose::Autobox:: prefix is the whole point. write it without and it just won't hit the same π
β METHODS β
mixin_additional_role ($type, $role)β this will mixin an additional$roleinto a certain$type. the types can beSCALAR,ARRAY,HASHorCODE.
this can be used to add additional methods to the types, see the examples/units/ directory for some examples. β¨
π TODO π
- More docs
- More tests
(lowkey relatable, we all have a TODO list we're avoiding π )
π SUPPORT π
bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Moose-Autobox> (or bug-Moose-Autobox@rt.cpan.org <mailto:bug-Moose-Autobox@rt.cpan.org>).
there is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/moose.html>.
there is also an irc channel available for users of this distribution, at #moose on irc.perl.org <irc://irc.perl.org/#moose>.
π AUTHOR π
Stevan Little <stevan.little@iinteractive.com>
π CONTRIBUTORS π
- Ricardo Signes <rjbs@cpan.org>
- Karen Etheridge <ether@cpan.org>
- Anders Nor Berle <berle@cpan.org>
- Matt S Trout <mst@shadowcat.co.uk>
- Steffen Schwigon <ss5@renormalist.net>
- Michael Swearingen <mswearingen@gmail.com>
- Florian Ragwitz <rafl@debian.org>
- Jonathan Rockway <jon@jrock.us>
- Shawn M Moore <sartak@gmail.com>
- Todd Hepler <thepler@employees.org>
- David Steinbrunner <dsteinbrunner@pobox.com>
- Mike Whitaker <mike@altrion.org>
- Nigel Gregoire <nigelgregoire@gmail.com>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2006 by Infinity Interactive, Inc.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page, you ate it, periodt π
. this was perl v5.34.0 doing its thing on 2022-06-15, and that's a wrap bestie β go call ->map on an array and feel something πΈπβ¨
π¦ where this page comes from
- debian bookworm: libmoose-autobox-perl 0.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoose-autobox-perl 0.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoose-autobox-perl 0.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoose-autobox-perl 0.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoose-autobox-perl 0.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms