|
NAMEObject::Enum - replacement for "if ($foo eq 'bar')"SYNOPSISuse Object::Enum qw(Enum); my $color = Enum([ qw(red yellow green) ]); # ... later if ($color->is_red) { # it can't be yellow or green EXPORTSSee Sub::Exporter for ways to customize this module's exports.EnumAn optional shortcut for "Object::Enum->new".CLASS METHODSnewmy $obj = Object::Enum->new(\@values); # or $obj = Object::Enum->new(\%arg); Return a new Object::Enum, with one or more sets of possible values. The simplest case is to pass an arrayref, which returns an object capable of having any one of the given values or of being unset. The more complex cases involve passing a hashref, which may have the following keys:
OBJECT METHODSspawnclonemy $new = $obj->clone; my $new = $obj->clone($value); Create a new Enum from an existing object, using the same arguments as were originally passed to "new" when that object was created. An optional value may be passed in; this is identical to (but more convenient than) calling "value" with the same argument on the newly cloned object. This method was formerly named "spawn". That name will still work but is deprecated. valueThe current value as a string (or undef)Note: don't pass in undef; use the unset method instead. valuesThe possible values for this objectunsetUnset the object's value (set to undef)is_*set_*Automatically generated from the values passed into "new".None of these methods take any arguments. The "set_*" methods are chainable; that is, they return the object on which they were called. This lets you do useful things like: use Object::Enum Enum => { -as => 'color', values => [qw(red blue)] }; print color->set_red->value; # prints 'red' AUTHORHans Dieter Pearcey, "<hdp at cpan.org>"BUGSPlease report any bugs or feature requests to "bug-object-enum at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-Enum>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc Object::Enum You can also look for information at:
ACKNOWLEDGEMENTSCOPYRIGHT & LICENSECopyright 2006 Hans Dieter Pearcey, all rights reserved.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |