Name : perl-enum
| |
Version : 1.12
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.35
| Date : 2024-08-05 17:54:19
|
Group : Unspecified
| Source RPM : perl-enum-1.12-1.35.src.rpm
|
Size : 0.04 MB
| |
Packager : (none)
| |
Summary : C style enumerated types and bitmask flags in Perl
|
Description :
This module is used to define a set of constants with ordered numeric values, similar to the \'enum\' type in the C programming language. You can also define bitmask constants, where the value assigned to each constant has exactly one bit set (eg 1, 2, 4, 8, etc).
What are enumerations good for? Typical uses would be for giving mnemonic names to indexes of arrays. Such arrays might be a list of months, days, or a return value index from a function such as localtime():
use enum qw( :Months_=0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec :Days_=0 Sun Mon Tue Wed Thu Fri Sat :LC_=0 Sec Min Hour MDay Mon Year WDay YDay Isdst );
if ((localtime)[LC_Mon] == Months_Jan) { print \"It\'s January!\ \"; } if ((localtime)[LC_WDay] == Days_Fri) { print \"It\'s Friday!\ \"; }
This not only reads easier, but can also be typo-checked at compile time when run under *use strict*. That is, if you misspell *Days_Fri* as *Days_Fry*, you\'ll generate a compile error.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-E/openSUSE_Tumbleweed/noarch |