http://www.perlmonks.org?node_id=1192453


in reply to Re: Is what you want available?
in thread Is what you want available?

How is adding even more typing user-friendly, especially when there is only 1 variable? Also, since there is only 1 language I have abbreviations for, it seems a bit silly to make a user type in a second variable for it, when I would have to do something like the following in the subroutine to make it read.

my $language = $opt{'lang'}.' '.$opt{'abbr'};

Wouldn't it be less of a headache to just have an all in one without splitting the hash key name between two variables?

my $month = random_month('English abbr'); -or- my $month = random_month( 'lang' => 'English', 'abbr' => 1 );

I also expanded the selection of languages and how the languages can be selected.

use Date::Calc qw(Month_to_Text); # supports 14 languages my %months = ( 'English' => [map(Month_to_Text($_, 1),(1..12))], 'en' => [map(Month_to_Text($_, 1),(1..12))], 'French' => [map(Month_to_Text($_, 2),(1..12))], 'français' => [map(Month_to_Text($_, 2),(1..12))], 'fr' => [map(Month_to_Text($_, 2),(1..12))], 'German' => [map(Month_to_Text($_, 3),(1..12))], 'Deutsch' => [map(Month_to_Text($_, 3),(1..12))], 'de' => [map(Month_to_Text($_, 3),(1..12))], 'Spanish' => [map(Month_to_Text($_, 4),(1..12))], 'Espańol' => [map(Month_to_Text($_, 4),(1..12))], 'es' => [map(Month_to_Text($_, 4),(1..12))], 'Portuguese' => [map(Month_to_Text($_, 5),(1..12))], 'Portuguęs' => [map(Month_to_Text($_, 5),(1..12))], 'pt' => [map(Month_to_Text($_, 5),(1..12))], 'Dutch' => [map(Month_to_Text($_, 6),(1..12))], 'Nederlands' => [map(Month_to_Text($_, 6),(1..12))], 'nl' => [map(Month_to_Text($_, 6),(1..12))], 'Italian' => [map(Month_to_Text($_, 7),(1..12))], 'Italiano' => [map(Month_to_Text($_, 7),(1..12))], 'it' => [map(Month_to_Text($_, 7),(1..12))], 'Norwegian' => [map(Month_to_Text($_, 8),(1..12))], 'Norsk bokmĺl' => [map(Month_to_Text($_, 8),(1..12))], 'nb' => [map(Month_to_Text($_, 8),(1..12))], 'Swedish' => [map(Month_to_Text($_, 9),(1..12))], 'svenska' => [map(Month_to_Text($_, 9),(1..12))], 'sv' => [map(Month_to_Text($_, 9),(1..12))], 'Danish' => [map(Month_to_Text($_, 10),(1..12))], 'dansk' => [map(Month_to_Text($_, 10),(1..12))], 'da' => [map(Month_to_Text($_, 10),(1..12))], 'Finnish' => [map(Month_to_Text($_, 11),(1..12))], 'suomi' => [map(Month_to_Text($_, 11),(1..12))], 'fi' => [map(Month_to_Text($_, 11),(1..12))], 'Hungarian' => [map(Month_to_Text($_, 12),(1..12))], 'magyar' => [map(Month_to_Text($_, 12),(1..12))], 'hu' => [map(Month_to_Text($_, 12),(1..12))], 'Polish' => [map(Month_to_Text($_, 13),(1..12))], 'język polski' => [map(Month_to_Text($_, 13),(1..12))], 'pl' => [map(Month_to_Text($_, 13),(1..12))], 'Romanian' => [map(Month_to_Text($_, 14),(1..12))], 'Română' => [map(Month_to_Text($_, 14),(1..12))], 'ro' => [map(Month_to_Text($_, 14),(1..12))], 'Greek' => [qw(Ianuários Fevruários Mártios Aprílios Máios Iú +nios Iúlios Avghustos Septémvrios Októvrios Noémvrios Thekémvrios)], 'el' => [qw(Ianuários Fevruários Mártios Aprílios Máios Iú +nios Iúlios Avghustos Septémvrios Októvrios Noémvrios Thekémvrios)], );

About fatal warnings, I leave them in for me. I consider all warnings as bad as errors, because something is not right with the code if I'm being warned about it. If I were to ever make any module "official", I would it them out.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re^3: Is what you want available?
by Arunbear (Prior) on Jun 10, 2017 at 13:23 UTC
    User friendliness includes having sensible defaults. English is a sensible default language. So if I wanted a random month in the default language I'd expect to be able to do
    my $month = random_month();
    Now if I wanted an abbreviated random month in the default language I'd expect to be able to do
    my $month = random_month(-abbrev => 1);
    Language and abbreviation are two distinct concepts, which indicates you need two parameters to handle them cleanly,