Skip to Content
Beginning Perl
book

Beginning Perl

by Curtis Ovid Poe
September 2012
Beginner
744 pages
15h 48m
English
Wrox
Content preview from Beginning Perl

Chapter 13

Moose

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • Understanding Moose Syntax including attributes, constructors, and inheritance
  • Using Type constraints, Method modifiers, roles, and popular Moose extensions
  • Understanding Moose Best Practices

WROX.COM CODE DOWNLOAD FOR THIS CHAPTER

The wrox.com code downloads for this chapter are found at http://www.wrox.com/remtitle.cgi?isbn=1118013847 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • example_13_1_person.pl
  • example_13_2_episode.pl
  • lib/Person.pm
  • lib/My/Company/Moose/Types.pm
  • lib/TV/Episode.pm
  • lib/TV/Episode/Broadcast.pm
  • listing_13_1_age.pl

In the beginning there was Perl and on the fifth version Larry blessed references and said, “Let there be objects” and all was good.

Well, sort of. Chapter 12 showed how to create objects with Perl’s builtin bless syntax, but there’s a lot of tedium in validating that your data is correct and setting up your classes properly. If you’re familiar with object-oriented programming (OOP) in other languages, you may have found Perl’s implementation to be a bit crufty. You’d be right.

To work around Perl’s rather simple object facilities, many programmers have taken a swing at making it easier to write objects. There is Class::MakeMethods, Class::MethodMaker, Class::BuildMethods, Class::Accessor, Object::Tiny, and so on. As of this writing, there are approximately 500 different packages in the Class:: and Object:: namespaces, many of which aren’t ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl

Mastering Perl

brian d foy
Learning Perl 6

Learning Perl 6

brian d foy
Perl & LWP

Perl & LWP

Sean M. Burke
Perl by Example

Perl by Example

Ellie Quigley

Publisher Resources

ISBN: 9781118235638Purchase book