saintex has asked for the wisdom of the Perl Monks concerning the following question:
package NavigationRules; our $VERSION=0.01; use Moose; use XML::Simple; use FindBin qw($Bin); use lib ("$Bin/classes"); has 'visitors' => (is=>'ro',isa=>'Int',required=>1,default=>1); #has 'numVisits' => (is=>'ro',isa=>'Int',default=>1); sub BUILD { my $self=shift; my $rules= XMLin("$Bin/conf/navigation_rules.xml",NormaliseSpace=> +2); $self->visitors=$rules->{navigation}->{visitors}; # $self->numVisits=$rules->{navigation}->{numVisits}; } __PACKAGE__->meta->make_immutable; 1;
Can't modify non-lvalue subroutine call at /home/wolf/Scrivania/naviga +tor/classes/NavigationRules.pm line 29.
But without success:has 'visitors' => (is=>'ro',isa=>'Int',writer=>'BUILD',required=>1);
You are overwriting a locally defined method (BUILD) with an accessor +at /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute.pm line 663
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose object construction
by CountZero (Bishop) on Feb 09, 2011 at 17:34 UTC | |
|
Re: Moose object construction
by thargas (Deacon) on Feb 09, 2011 at 16:31 UTC | |
by saintex (Scribe) on Feb 10, 2011 at 09:06 UTC | |
by stvn (Monsignor) on Feb 10, 2011 at 16:10 UTC | |
by thargas (Deacon) on Feb 10, 2011 at 17:17 UTC | |
by stvn (Monsignor) on Feb 11, 2011 at 00:47 UTC | |
| |
by thargas (Deacon) on Feb 10, 2011 at 13:12 UTC |