NAME
Devel::Ladybug::Enum - C style enumerated types as Perl constants
DESCRIPTION
This module emulates a subset of the functionality found in enum.pm. Unlike enum.pm, the symbols generated by this module are created as constants, and may be imported and exported as such.
ENUMERATIONS
Devel::Ladybug includes the following enumeration packages:
-
Provide
false
andtrue
enumerated constants -
Constant enumeration of supported backing store types
SYNOPSIS
use Devel::Ladybug::Enum qw(
Sun Mon Tue Wed Thu Fri Sat
Forty=40 FortyOne Five=5 Six Seven
);
Basic Usage
Create a quick package of enumerated constants:
#
# File: Month.pm
#
package Month;
use Devel::Ladybug::Enum qw|
jan feb mar apr may jun jul aug sep oct nov dec
|;
1;
Meanwhile, in caller:
#
# File: hangover.pl
#
use Month;
...
my $month = getMonth();
if ( $month == Month::jan ) {
print "Happy New Year\n";
}
Auto Export
Same usage as the Month.pm example above, with an extra block of code eval'd for Exporter.
#
# File: DayOfWeek.pm
#
package DayOfWeek;
use Devel::Ladybug::Enum qw| sun mon tue wed thu fri sat |;
eval { @EXPORT = @EXPORT_OK };
1;
Meanwhile, in caller:
#
# File: pizza-reminder.pl
#
use DayOfWeek;
...
my $day = getDayOfWeek();
if ( $day == fri ) {
print "It's pizza day!\n";
}
SEE ALSO
This file is part of Devel::Ladybug.