Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Moose examples

by Anonymous Monk
on Sep 02, 2009 at 08:33 UTC ( #792842=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know of a moderately complex (several classes, subclasses and preferably a roll or two), but complete and stand-alone (command line) program in the public domain?

Something that can be downloaded and run without involving too many dependencies beyond Moose itself.


Replies are listed 'Best First'.
Re: Moose examples
by stvn (Monsignor) on Sep 03, 2009 at 13:15 UTC

    Here are a couple suggestions from my CPAN directory, all of which are being used in production at my $work. Unfortunately the docs are kind of slim in many of them (not enough time in the day for me), but I think you are more interested in reading the code anyway. Be sure to also check out the test suites though, they are always helpful in the absence of docs.

    • Forest
    • Forest::Tree is a basic n-ary tree object, which is a pretty standard data structure so should be easy to understand. For examples of roles that are meant to be combined with Forest::Tree, take a look at Forest::Tree::Roles::HasNodeFormatter, Forest::Tree::Roles::MetaData and Forest::Tree::Roles::JSONable. The distro also comes with a number of utility modules, each of which has an interface role associated, such as Forest::Tree::Reader is the interface role for Forest::Tree::Reader::SimpleTextFile.

    • Text::Flow
    • This module is actually very simple, it is meant to fill the need for a non-ASCII-output text flow module. It makes light use of Moose here, but I thought it might be helpful.

    • Path::Router
    • This is Yet Another path routing/dispatching module. Each of the classes are pretty small and so easy to see what is going on.

    • Path::Class::Versioned
    • This is another pretty simple (but useful) module that makes interesting use of Moose type constraints. It also has some usage of MooseX::Params::Validate which is one of the nicer Moose extensions.

    • Lighttpd::Control
    • This a simple wrapper around the lighttpd web server, it will require that you have that to actually run this code, but the code itself should be pretty readable anyway. It makes use of a number of Moose features, such as; coercion, builders, predicates and clearers as well as augment/inner (which is the inverse of override/super). Again, the test suite is a good place to look.

    • FCGI::Engine
    • This module was an attempt to fill the gap with FastCGI deployment. Catalyst had some nice tools, but beyond that there was nothing so I took the good bits from Catalyst and added a few more myself. Of particular interest would probably be the FCGI::Engine::Types module as it has some nice and reasonably simple examples of type constraint usage. Also note that the FCGI::Engine module itself consumes the MooseX::Getopt role which allows it to be easily called from the command line.

    • Excel::Template::Plus
    • This is a wrapper around Excel::Template and I was particularly fond of some of the bits of Excel::Template::Plus::TT, specifically where we actually wrapped the Excel::Template object and delegated to methods.

    Outside of my own CPAN directory, I would also recommend looking at any of the following, many of which I have used myself and some of which I plan to use at some point.

    And here are some which are command-line-app specific.


      Thank you!

      For taking time from your obvious busy schedule, and expending considerable effort to present this information.

      I will review the code of, and where possible try out, every module noted, before responding further.

      I may be gone some time...

Re: Moose examples
by Anonymous Monk on Sep 02, 2009 at 12:21 UTC

      The problem is, of those 600 packages:

    • 25% are Moose extensions, or for testing Moose itself.
    • 25% are Moose components of large frameworks like Catalyst, DBI & Mason.
    • Another 25% of them have specialist dependencies like Amazon S3, Hadoop, Twitter, Jabber, KiokuDB, POE.

      Of those remaining, they are mostly peoples own experiments that are neither examples of good Moose practice, nor incomplete. Eg. Acme::Mahjong.

      It seems that despite three plus years and all the hype, it's mostly Moose (and one or two in-house projects) that is using Moose.

      And that can possibly be attributed to the complete dearth of examples of applications that use Moose to do real work, rather than cutesy examples to demonstrate it feature set.

        I think my reply below addresses your comments regarding the suitability of those 600 packages. I will agree that it is hard to know what to look at in such a long list, so your frustration is understandable.

        It seems that despite three plus years and all the hype, it's mostly Moose (and one or two in-house projects) that is using Moose.

        Well, this is very much not true. Of course you have no real way of knowing these things as your obviously not working at one of the companies that makes use of Moose :)

        I addressed a similar statement in this reply a while back, but Moose has grown even more since then and the list has expanded. We have built apps using Moose that are used by Walmart, Marriott Hotels, Grey Advertising and Aetna Insurance to name a few. I know for sure that Moose is being used (in some non-trivial capacity) at Yahoo!, Symatec, IMDB, Pobox, Best Practical, ValueClick,, Reuters,, BBC, Hearst Publishing and SocialText. I know of at least two Bioinformatics projects that are using it (and there is a BioMoose project going on to port BioPerl to Moose). I heard rumors that it is being used at Amazon and possibly within Google (it was part of the "Perl on Google App Engine" push at first but the steam seems to have run out on that project now). There has been a steady couple of jobs on which ask for Moose experience over the last couple of months. And last but not least, while it is most certainly Not Safe For Work, YouPorn is one of the most visited sites on the internet and run completely on Perl and making use of Moose.

        And that can possibly be attributed to the complete dearth of examples of applications that use Moose to do real work, rather than cutesy examples to demonstrate it feature set.

        I think again my reply below addresses this, many of these modules do very real work. Unfortunately it is rather hard to see "real work" examples because they are usually proprietary and all that you get to see is what portions of that work were re-usable enough to send to CPAN.

        Anyway, hope this clears up any misconceptions that you might have accumulated.


        I'd also like to point out that this sort of usage/distribution is exactly what you'd expect for something like Moose. It's not List::Util or something which is simple, functional, small and easy to drop into almost any regular code. It's a deep, feature rich, highly extensible mini-system for OO. Lingua::Stopwords is a goofy candidate for Moose. Catalyst is an ideal candidate.

        And this is why Moose is so nice. It makes building big, complex things straightforward and easy to maneuver.

      For a colourful and well-designed visual alternative, check out, where you can look up dependencies and reverse dependencies and see them across the whole CPAN in a concise, single-window interactive graphical display.

      Reverse dependencies of Moose

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://792842]
Approved by moritz
Front-paged by Arunbear
and not a whimper to be heard...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-08-21 01:14 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (317 votes). Check out past polls.