Questions tagged [moose]

Moose is a postmodern object system for Perl 5 that takes the tedium out of writing object-oriented Perl. It borrows all the best features from Perl 6, CLOS (Lisp), Smalltalk, Java, BETA, OCaml, Ruby and more, while still keeping true to its Perl 5 roots.

Moose is an extension of the Perl 5 object system. The main goal of Moose is to make Perl 5 object-oriented programming (OOP) easier, more consistent and less tedious. With Moose you can think more about what you want to do and less about the mechanics of OOP.

Moose links

See Also

sources: moose.perl.org

609 questions
42
votes
11 answers

Should I learn Perl 5 OO or Moose first?

I'm still relatively new to Perl Programming, but I know how Perl 5 OO basically works. However, I have never created any project with Perl 5 OO, so I'm quite sure I will run into many pitfalls. Recently I discovered the hype about the Moose module.…
Simon
  • 1,643
  • 2
  • 17
  • 23
31
votes
3 answers

Can anybody please explain (my $self = shift) in Perl

I'm having a really hard time understanding the intersection of OO Perl and my $self = shift; The documentation on these individual elements is great, but none of them that I've found touch on how they work together. I've been using Moose to make…
Alex H Hadik
  • 774
  • 2
  • 7
  • 16
23
votes
3 answers

How to make Mason2 UTF-8 clean?

Reformulating the question, because @optional asked me it wasn't clear and linked one HTML::Mason based solution Four easy steps to make Mason UTF-8 Unicode clean with Apache, mod_perl, and DBI , what caused confusions the original is 4 years old…
kobame
  • 5,766
  • 3
  • 31
  • 62
21
votes
2 answers

How do Roles and Traits differ in Moose?

I have written a set of classes and interfaces that are implemented in Moose also using roles. What I am having trouble understanding is the exact differences in both usage and implementation of Moose traits vs. roles. The Moose documentation…
Danny
  • 13,194
  • 4
  • 31
  • 36
20
votes
4 answers

In Moose, how do I modify an attribute any time it is set?

If you have an attribute that needs to be modified any time it is set, is there a slick way of doing this short of writing the accessor yourself and mucking around directly with the content of $self, as done in this example? package Foo; use…
FMc
  • 41,963
  • 13
  • 79
  • 132
19
votes
5 answers

Modern perl - ready to run applications - learning by examples - from what?

I'm learning Modern perl - Moose, Plack etc. In much advices you can read "learn by examples" - so started searching for some ready-to-run applications written with Modern perl. Browsed much pages…
kobame
  • 5,766
  • 3
  • 31
  • 62
19
votes
5 answers

How can I create internal (private) Moose object variables (attributes)?

I would like some attributes (perhaps this is the wrong term in this context) to be private, that is, only internal for the object use - can't be read or written from the outside. For example, think of some internal variable that counts the number…
David B
  • 29,258
  • 50
  • 133
  • 186
19
votes
9 answers

Is checking Perl function arguments worth it?

There's a lot of buzz about MooseX::Method::Signatures and even before that, modules such as Params::Validate that are designed to type check every argument to methods or functions. I'm considering using the former for all my future Perl code, both…
rjh
  • 49,276
  • 4
  • 56
  • 63
19
votes
5 answers

Resources for getting started on "modern" Perl

After having heard about new parts of the Perl ecosystem, such as Moose, DeclareX, and Catalyst, I thought that it'd be nice to take a look at Perl. Unfortunately, all of the introductory material I can find targets Perl 5.8 or 5.6, and knows…
Benjamin Pollack
  • 27,594
  • 16
  • 81
  • 105
18
votes
4 answers

Perl::Critic: Life after Moose?

I've started a conversion of a project to Moose and the first thing I noticed was that my critic/tidy tests go to hell. Moose, Tidy and Critic don't seem to like each other as much as they used to. Are there docs anywhere on how to make critic/tidy…
claco
  • 739
  • 1
  • 8
  • 18
17
votes
2 answers

How does Moose compare to Python's OO system?

My original question was too vague and was "closed as not constructive." As such, I will revise the question so that it caters to the answers that have already been posted. :-) I am interested in the differences between Perl's Moose OO framework…
David Mertens
  • 1,037
  • 8
  • 12
17
votes
4 answers

Moose vs. MooseX::Declare

POSTLUDE MooseX::Declare would no longer be recommended by anyone as it relies on Devel::Declare which served its purpose but is itself obsolete. At this point if anyone wants MX::D they should look at Moops ORIGINAL Assuming I already have a decent…
Joel Berger
  • 20,180
  • 5
  • 49
  • 104
16
votes
3 answers

Moose "builder" vs "default"

I understand that using builder enables subclasses to override attribute defaults easily and roles can require them. This can also be accomplished using default like so: has 'foo' => is => 'rw', isa => 'Str', default => sub…
Schwern
  • 153,029
  • 25
  • 195
  • 336
15
votes
1 answer

Why is "use namespace::autoclean" preferred to "no Moose"?

An often seen recommendation on best practices regarding Moose is the following: "The use namespace::autoclean bit is simply good code hygiene, as it removes imported symbols from your class's namespace at the end of your package's compile cycle,…
15
votes
3 answers

How to (continue) learn Moose for using it "fairly" well?

Although I am not a Perl guru, I use Perl and I can write object-oriented programs the "good old" way. Now I would like to learn Moose. I've already (so-as) chewed the basic documentation, and my first Moose and roles are already working, but I'm…
cajwine
  • 3,100
  • 1
  • 20
  • 41
1
2 3
40 41