in reply to Re^4: Moose Attribute Default Dependency
in thread Moose Attribute Default Dependency

What do you expect this to do?

my $self;

What do you expect this to do?

                     default   => $self->{Dbase}.'/come/on/now',

Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^6: Moose Attribute Default Dependency
by dpath2o (Acolyte) on Nov 13, 2013 at 02:30 UTC

    I expect

    my $self;

    will 'initialise' $self to allow

    default => $self->{Dbase}.'/come/on/now',

    it to be used.

    I now realise that this not OK and I must use builder.

      You don't have to use builder, this also works:

      has 'x' => ( is => 'rw', isa => 'Str', default => sub { my ($self) = @_; return $self->value; }, lazy => 1, );

      By the way, I should have said this earlier, I strongly second chromatic's suggestion!

      The answer to the question "Can we do this?" is always an emphatic "Yes!" Just give me enough time and money.