in reply to Re: Moose required creates empty object Can't locate object method "x" via package "Point"
in thread Moose required creates empty object Can't locate object method "x" via package "Point"

You can remove a lot unnecessary "scaffolding" from your code:

#!/usr/bin/perl package Point; use Moose; has 'x' => (isa => 'Int', is => 'rw', required => 1); has 'y' => (isa => 'Int', is => 'rw', required => 1); sub clear { my $self = shift; $self->x(0); $self->y(0); } package main; use strict; use warnings; print Point->new->dump; print Point->new({})->dump; print Point->new({})->x; __END__ Attribute (x) is required at /PATH/TO/Moose/Object.pm line 24 Moose::Object::new('Point') called at foo.pl line 17
Strange things can happen when you don't put your modules into a proper lib/ dir, etc. etc. ... but i love and utilize the convenience of being able to put everything into one source file from time to time. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re^2: Moose required creates empty object Can't locate object method "x" via package "Point"
  • Download Code

Replies are listed 'Best First'.
Re^3: Moose required creates empty object Can't locate object method "x" via package "Point"
by Anonymous Monk on May 18, 2015 at 22:24 UTC

    You can remove a lot unnecessary "scaffolding" from your code:

    What a ridiculous statement

    Strange things can happen when you don't put your modules into a proper lib/ dir, etc. etc. ...

    Nothing really strange, order of operations matters even to moose

      What a ridiculous statement

      What a ridiculous comment. Care to detail?

      Nothing really strange, order of operations matters even to moose

      More vague jibberish. Care to actually ask questions or do you just want to troll?