Does Perl have an enumeration type that adheres to best practices, or maybe more importantly, does it need one?
The project I am working one uses strings all over the place to denote things that would typically use an Enum in a language like C#. For example, we have a set of phone numbers in an array of hashes, each associated with a phone type ("Home", "Work", "Mobile", etc.):
$phone_number->{type} = 'Home';
Would it be sufficient to use a read-only set of variables here or should an Enum be used? I've found an enum
module on CPAN but it appears to use bare words which violates one of the Perl Best Practices. My thinking on using read-only variables goes something like this:
use Readonly;
Readonly my $HOME => 'Home';
Readonly my $WORK => 'Work';
Readonly my $MOBILE => 'Mobile';
$phone_number->{type} = $HOME;
Is this a good approach or is there a better way?