Hello Monks,
I wrote a module recently for work that I was also considering uploading to CPAN. I am still unsure of the name space, too. Anyways, after an insightful peer review, my essential question is: should I use Moose at all? I understand that this is a pretty small module- which may mean making the dependency silly. The module will take a country code from the user and return a status for it. I considered using the Locale::Country name space, but I'm not a huge fan of how it is used for getting country codes:
https://metacpan.org/pod/distribution/Locale-Codes/lib/Locale/Country.pod
Any insight is greatly appreciated :)
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;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.