Hmmm... did you notice that you defined "Myclass", then tried: "MyClass->new"?
-Chris On May 11, 2012 6:42 AM, "Emmanuel Quevillon" <t...@pasteur.fr> 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; > > > Later when I use my Class, I get the following error : > > my $c = MyClass->new(file => '/tmp/foobar'); > > Can't use string ("MyClass") as a HASH ref while "strict refs" in use at > accessor MyClass::file (defined at > /home/tuco/src/workspace/**cnvdb/script/../lib/Class.pm > line 7) > > > > Can someone light my lantern? > > Sorry for the stupid question > > Regards > > > -- > ------------------------- > Emmanuel Quevillon > CIB, Centre Informatique pour la Biologie > Institut Pasteur > +33 1 44 38 95 98 > tuco at_ pasteur dot fr > ------------------------- >