My OO style is simple and clean, thanks to Attribute::Property:
And this is how you use this Some::Class:package Some::Class; sub new : New { my ($self) = @_; exists $self->{$_} or croak "Mandatory argument '$_' missing" for qw(id foo); return $self; } sub id : Property { /^\d+\z/ } sub foo : Property; sub bar : Property; sub blah : Property { $_ < 50 } sub _private : method { my ($self) = @_; ... } sub do_something : method { my ($self, $quux) = @_; ... }
See also $foo->bar = 14; and $foo->bar = 14; revisited: Attribute::Property.my $thing = Some::Class->new( id => 15, foo => "Hello" ); $thing->foo =~ s/e/a/; $thing->id++; $thing->do_something($$); $thing->blah = 10; $thing->blah = 60; # dies
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In reply to Re: How do YOU do OO in Perl?
by Juerd
in thread How do YOU do OO in Perl?
by batkins
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |