| 1 | package Readonly::Values::Days; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Readonly::Enum; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Exporter qw(import); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Readonly::Values::Days - Days Constants | ||||||||||
| 13 | |||||||||||
| 14 | =head1 VERSION | ||||||||||
| 15 | |||||||||||
| 16 | Version 0.01 | ||||||||||
| 17 | |||||||||||
| 18 | =cut | ||||||||||
| 19 | |||||||||||
| 20 | 1 | our $VERSION = '0.01'; | |||||||||
| 21 | |||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||
| 23 | |||||||||||
| 24 | use Readonly::Values::Days; | ||||||||||
| 25 | |||||||||||
| 26 | # Iterate full day names | ||||||||||
| 27 | for my $name (@day_names) { | ||||||||||
| 28 | printf "%-9s => %2d\n", ucfirst($name), $days{$name}; | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | 1 | Readonly::Enum our ($MON, $TUE, $WED, $THU, $FRI, $SAT, $SUN) => 1; | |||||||||
| 34 | |||||||||||
| 35 | 1 | Readonly::Hash our %days => ( | |||||||||
| 36 | # Full names | ||||||||||
| 37 | 'monday' => $MON, | ||||||||||
| 38 | 'tuesday' => $TUE, | ||||||||||
| 39 | 'wednesday' => $WED, | ||||||||||
| 40 | 'thursday' => $THU, | ||||||||||
| 41 | 'friday' => $FRI, | ||||||||||
| 42 | 'saturday' => $SAT, | ||||||||||
| 43 | 'sunday' => $SUN, | ||||||||||
| 44 | |||||||||||
| 45 | # Abbreviations | ||||||||||
| 46 | 'mon' => $MON, | ||||||||||
| 47 | 'tue' => $TUE, | ||||||||||
| 48 | 'wed' => $WED, | ||||||||||
| 49 | 'thu' => $THU, | ||||||||||
| 50 | 'fri' => $FRI, | ||||||||||
| 51 | 'sat' => $SAT, | ||||||||||
| 52 | 'sun' => $SUN | ||||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 1 | Readonly::Array our @day_names => ( | |||||||||
| 56 | 'monday', | ||||||||||
| 57 | 'tuesday', | ||||||||||
| 58 | 'wednesday', | ||||||||||
| 59 | 'thursday', | ||||||||||
| 60 | 'friday', | ||||||||||
| 61 | 'saturday', | ||||||||||
| 62 | 'sunday' | ||||||||||
| 63 | ); | ||||||||||
| 64 | |||||||||||
| 65 | 1 | Readonly::Array our @short_day_names => map { _shorten($_) } @day_names; | |||||||||
| 66 | |||||||||||
| 67 | 1 | Readonly::Hash our %day_names_to_short => map { $_ => _shorten($_) } @day_names; | |||||||||
| 68 | |||||||||||
| 69 | 1 | our @EXPORT = qw( | |||||||||
| 70 | $MON $TUE $WED $THU $FRI $SAT $SUN | ||||||||||
| 71 | %days | ||||||||||
| 72 | @day_names | ||||||||||
| 73 | @short_day_names | ||||||||||
| 74 | %day_names_to_short | ||||||||||
| 75 | ); | ||||||||||
| 76 | |||||||||||
| 77 | # Helper routine: Shorten strings to their first three characters | ||||||||||
| 78 | 20 | ▶ | sub _shorten { | ||||||||
|
Subroutine
_shorten: called CC=2 SCAR=6.9
| |||||||||||
| 79 | 20 | my $str = $_[0]; | |||||||||
| 80 | |||||||||||
| 81 | 20 | ▶ | return unless defined $str; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 19 | return substr($str, 0, 3); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | =head1 AUTHOR | ||||||||||
| 86 | |||||||||||
| 87 | Nigel Horne, C<< <njh at nigelhorne.com> >> | ||||||||||
| 88 | |||||||||||
| 89 | =head1 BUGS | ||||||||||
| 90 | |||||||||||
| 91 | =head1 SEE ALSO | ||||||||||
| 92 | |||||||||||
| 93 | =head1 SUPPORT | ||||||||||
| 94 | |||||||||||
| 95 | This module is provided as-is without any warranty. | ||||||||||
| 96 | |||||||||||
| 97 | Please report any bugs or feature requests to C<bug-readonly-values-days at rt.cpan.org>, | ||||||||||
| 98 | or through the web interface at | ||||||||||
| 99 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Readonly-Values-Days>. | ||||||||||
| 100 | I will be notified, and then you'll | ||||||||||
| 101 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 102 | |||||||||||
| 103 | You can find documentation for this module with the perldoc command. | ||||||||||
| 104 | |||||||||||
| 105 | perldoc Readonly::Values::Days | ||||||||||
| 106 | |||||||||||
| 107 | You can also look for information at: | ||||||||||
| 108 | |||||||||||
| 109 | =over 4 | ||||||||||
| 110 | |||||||||||
| 111 | =item * MetaCPAN | ||||||||||
| 112 | |||||||||||
| 113 | L<https://metacpan.org/dist/Readonly-Values-Days> | ||||||||||
| 114 | |||||||||||
| 115 | =item * RT: CPAN's request tracker | ||||||||||
| 116 | |||||||||||
| 117 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Readonly-Values-Days> | ||||||||||
| 118 | |||||||||||
| 119 | =item * CPAN Testers' Matrix | ||||||||||
| 120 | |||||||||||
| 121 | L<http://matrix.cpantesters.org/?dist=Readonly-Values-Days> | ||||||||||
| 122 | |||||||||||
| 123 | =item * CPAN Testers Dependencies | ||||||||||
| 124 | |||||||||||
| 125 | L<http://deps.cpantesters.org/?module=Readonly::Values::Days> | ||||||||||
| 126 | |||||||||||
| 127 | =back | ||||||||||
| 128 | |||||||||||
| 129 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 130 | |||||||||||
| 131 | Copyright 2025 Nigel Horne. | ||||||||||
| 132 | |||||||||||
| 133 | Usage is subject to licence terms. | ||||||||||
| 134 | |||||||||||
| 135 | The licence terms of this software are as follows: | ||||||||||
| 136 | |||||||||||
| 137 | =over 4 | ||||||||||
| 138 | |||||||||||
| 139 | =item * Personal single user, single computer use: GPL2 | ||||||||||
| 140 | |||||||||||
| 141 | =item * All other users (including Commercial, Charity, Educational, Government) | ||||||||||
| 142 | must apply in writing for a licence for use from Nigel Horne at the | ||||||||||
| 143 | above e-mail. | ||||||||||
| 144 | |||||||||||
| 145 | =back | ||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||
| 148 | |||||||||||
| 149 | 1 | 1; | |||||||||