First page Back Continue Last page Overview Graphics

Clarity and Structure

Non-Moose Code :-( package Moosificate; use strict; use warnings; use Carp 'confess'; sub new { my $class = shift; my %args = @_; my $self = {}; if (exists $args{y}) { confess "Attribute (y) does not pass the type constraint because: Validation failed for 'Str' with value $args{y}" if ref($args{y}); $self->{y} = $args{y}; } return bless $self, $class; } sub y { my $self = shift; if (@_) { my $value = shift; confess "Attribute (y) does not pass the type constraint because: Validation failed for 'Str' with value $value" if ref($value); $self->{y} = $value; } return $self->{y}; }