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
0
votes
1 answer

MooseX::Getopt - canonical way to specify usage message

What's the usual way to include "usage" text in a program using MooseX::Getopt? (i.e. running myprog --usage should print something like "myprog: make everything great") The MooseX::Getopt documentation says: "If Getopt::Long::Descriptive is…
gcbenison
  • 11,723
  • 4
  • 44
  • 82
0
votes
1 answer

Why declare a subroutine that returns a subroutine reference in Moose?

im new to Moose in perl, and i have been reading its documentation when i encountered this one which i dont quite understand: If you want to use a reference of any sort as the default value, you must return it from a subroutine. OK i get this…
Belmark Caday
  • 1,623
  • 3
  • 21
  • 29
0
votes
1 answer

Using Moose in Perl to implement a functor

I'm working with some code in Perl that wants me to pass a method to it. But, I'd like to keep some state about what happens in the method. I know I can use a global variable for this, but I'd prefer something a little cleaner/object oriented. Is…
JamieC
  • 87
  • 6
0
votes
1 answer

Moose Perl Vs oop Perl ?

what are the differences between moose Perl and oop Perl ? why we are using Moose Perl in place of oop Perl?
user1363308
  • 938
  • 4
  • 14
  • 33
0
votes
2 answers

How do I install the dependencies I need for MySQL::Slurp?

I am trying to install the mysqlslurp utility found in MySQL::Slurp. I found that it requires Moose and therefore I installed that package too. But I am still not able to use the mysqlslurp command. I get an error: Can't locate Moose.pm in @INC…
shantanuo
  • 31,689
  • 78
  • 245
  • 403
0
votes
1 answer

Moose and Roles method modifers

It is possible to use an after modifier in a Role for a required attribute that is populated in the consuming class via a builder method? package A::Role; use Moose::Role; use IO::File; use Carp; requires 'properties_file'; after 'properties_file'…
snoofkin
  • 8,725
  • 14
  • 49
  • 86
0
votes
1 answer

Find all Attributes with given Trait

I've looked and looked but can't seem to find a Moose::Meta function to return all Attributes that have a given trait. Is this possible?
Ryan
  • 672
  • 1
  • 6
  • 16
0
votes
2 answers

Compile time issue with MooseX::Aliases, immutable and circular 'use'

I get a compile time error (Moose complains about modifying an immutable instance) running 'perl -c' on a package but code using the package runs error-free. Example Code: File Pa_1.pm (immutable Moose class using MooseX::Aliases and package…
katastrophos
  • 521
  • 4
  • 17
0
votes
1 answer

coerce from hashref on all types

I have the following code duplicated several times as I have several classes that follow the same pattern use MooseX::Types -declare [ qw( Item ) ];jj my $itc = $prefix . 'Item'; class_type Item, { class => $itc }; coerce Item, from HashRef, via {…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
0
votes
2 answers

What's happening with this DBI:db object when errstr is called?

I'm delegating an attribute in my current class called 'dbc' as a DBIx::Connector so that I can call $self->dbc->dbh from inside methods, however I'm not really understanding some behaviors I'm seeing when calling the 'errstr' method on the DBI::db…
Chris Matta
  • 3,263
  • 3
  • 35
  • 48
0
votes
1 answer

Defining attibute trigger in parameterized roles does not work - not allowed/impossible?

In the follwoing code I tried to define a trigger for an attribute within a parameterized role. #!/usr/bin/env perl package WordSizeRoleParameterized; use MooseX::Role::Parameterized; # a parameterized role with a trigger for an attribute # does…
katastrophos
  • 521
  • 4
  • 17
0
votes
1 answer

Get an attributes value from within the attribute

In the Moose Extension I'm writing I'm trying to access the attributes value from within the attribute, without going through the accessor, but I can't seem to get this right. I'm trying to be able to write this code { package Test; use…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
-1
votes
1 answer

Perl Moose attribute handles set method

Defined a HashRef attribute in the lines of 'options' example. has 'clsHsh' => ( traits => ['Hash'], is => 'rw', isa => 'HashRef[Str]', default => sub {{}}, handles => { …
-1
votes
2 answers

Perl Moose default value not set

I am using strawberry perl Moose 2.0010 In the class: package Cat; use 5.010; use strict; use Moose; has 'name', is => 'ro', isa => 'Str', default => 'Beauty'; #has 'age', is => 'ro'; has 'diet', is => 'rw', default => 'fish'; has…
Weiyan
  • 1,116
  • 3
  • 14
  • 25
-1
votes
1 answer

Extending a Moose class to enable use of different classes internally

I'm fairly new to Moose and OO programming. Looking for some guidance. I've got the following Dir Moose class that builds a listing of File objects: #!usr/bin/perl package Dir; use Moose; use Modern::Perl; has 'files' => (is => 'rw', isa…
StevieD
  • 6,925
  • 2
  • 25
  • 45
1 2 3
40
41