in reply to Object not created as well with Moose

Is the package name the name you want?

package Package::Systen::Foo;

If so, then you will need to show us some code where you actually use things.

  • Comment on Re: Object not created as well with Moose

Replies are listed 'Best First'.
Re^2: Object not created as well with Moose
by woodpeaker (Novice) on Dec 10, 2008 at 22:03 UTC
    #!/usr/bin/perl -w use strict; use Package::System::Foo; use Data::Dumper; my $foo = Package::System::Foo->new(); $foo->start(); print Dumper $foo;
    package Package::System::Foo; use Moose; extends 'Package::Contol::Base::Daemon::Server'; use Package::System::Config; has 'CONFIG' => (is=>'rw',isa=>'Object'); # OR I tried isa=>'Any' sub _init{ my $self = shift; $self->CONFIG(Package::System::Config->new()); #not executing after that } sub start{ my $self = shift; $self->_init(); # not executing after _init() ......... } 1;
    package Package::Contol::Base::Daemon::Server; use Moose; has 'DAEMON' => (is=>rw,isa=>'Object'); 1;
    'Package' it's just sample. I cannot show real module name for some reason, sorry.
      Try re-reading Corion's comment.

      It points out a typo in your SOPW.

      If you wrap your Moose class definitions in a BEGIN {} block it should work correctly. This is needed because the Moose "keywords" are just plain perl functions and so in the example you show above, they will not have run prior to your test code running.

      Also, _init has no meaning to Moose, you must be looking for BUILD.

      -stvn