What about Perl 6?
A lot of the features in Moose were inspired by Perl 6. Perl 6 still is being
developed actively, and I believe that when it’s finally released for production
use, it won’t disappoint. The fact is Perl 5 is solid, proven and fast, so there
is no reason to rush Perl 6. It is better that the developers take the time to
do it really right, which is exactly what they’re doing.
At the end of the day, it’s just syntax.
The good news is you don’t need to
master Perl by any stretch to start
Perl does have its quirks, and Moose
doesn’t make them all totally go away
(and you wouldn’t want them all to
go away, because a lot of them are
really useful). The most important
concepts to understand are how Perl
references work (the “perlreftut”
tutorial is a great place to start—see
Resources), and also the basics of
working with Scalars, Arrays and
Hashes. Also, learn what the fat
comma is (=>) if you aren’t already
familiar with it. Moose makes heavy
use of it as an idiom. It’s actually not
that scary; it’s interchangeable with
the normal comma (,).
Most of the rest of it you can learn
as you go. Normal language stuff like
loops, conditionals and operators aren’t
all that different in Perl than any other
language. So give it a shot. I think you’ll
find it’s well worth the investment.
Chances are you already have a distribution of Perl installed on your system.
You at least should have Perl 5. 8, but
preferably 5. 10 or 5. 12. Installing Moose
from CPAN is an easy task; simply run
the following command:
This should download and install
Moose for you, as well as all of Moose’s
Object-Oriented Perl (the Old Way)
Even though Perl has had object-oriented
features for a long time, it was not
originally designed—syntactically—as an
object-oriented language. This is more
about the API provided to the programmer than it is about the underlying
technical design of Perl itself.
Perl 5 provides a lean environment
with the fundamental features and hooks
needed for object-oriented programming,
but then leaves most of the details (such
WWW.LINUXJOURNAL.COM SEPTEMBER 2011 | 125