PerlSufi has asked for the wisdom of the Perl Monks concerning the following question:
package My::Module; use strict; use warnings; use Moose; use namespace::autoclean; use Carp; use feature 'switch'; has country_code => ( is => 'rw', isa => 'Str', required => 1, ); has sanction => ( is => 'ro', isa => 'Bool', lazy => 1, writer => 'set_sanction', reader => 'get_sanction', default => 0, ); sub status { my $self = shift; my $country_code = shift; given ($country_code) { when (m/MMR|MM/) { $self->set_sanction(1) } when (m/IRN|IR/) { $self->set_sanction(1) } when (m/CUB|CU/) { $self->set_sanction(1) } when (m/SSD|SS/) { $self->set_sanction(1) } when (m/PRK|PK/) { $self->set_sanction(1) } when (m/SYR|SY/) { $self->set_sanction(1) } when ( !defined ) { croak "Country Code undefined"; } } my $result = $self->get_sanction; return $result; } __PACKAGE__->meta->make_immutable; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: To Moose or not To Moose.. ?
by Your Mother (Archbishop) on Jun 09, 2014 at 17:59 UTC | |
by PerlSufi (Friar) on Jun 09, 2014 at 20:51 UTC | |
|
Re: To Moose or not To Moose.. ?
by boftx (Deacon) on Jun 09, 2014 at 18:02 UTC | |
by perlfan (Parson) on Jun 09, 2014 at 20:48 UTC | |
by arkturuz (Curate) on Jun 10, 2014 at 08:30 UTC | |
by PerlSufi (Friar) on Jun 09, 2014 at 20:52 UTC | |
by boftx (Deacon) on Jun 09, 2014 at 20:58 UTC |