On Fri, May 11, 2012, at 15:42, Emmanuel Quevillon wrote:
> Hi,
>
> I got an exception when using 'after' this way.
> Here is my Moose class :
>
> package Myclass;
>
> use Moose;
> extends 'SuperClass';
> with 'MyRole';
>
> has 'file' => (is => 'rw', isa => 'Str', required => 1);
> has 'fh' => (is => 'rw', isa => 'FileHandle');
>
> after 'new' => sub {
> my $self = shift;
> my $file = $self->file();
> $self->set_fh($self->open_file($file)); # Returns a FileHandle obj
> return 0;
> };
>
> 1;
You don't have a 'new' attribute to hook 'after'.
The technical name for "after 'new' => sub {" is "sub BUILD {". See
Moose::Cookbook::Basics::Person_BUILDARGSAndBUILD for more details.
--Curtis Jewell
--
Curtis Jewell
[email protected]
%DCL-E-MEM-BAD, bad memory
-VMS-F-PDGERS, pudding between the ears