GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Object::Enum(3) User Contributed Perl Documentation Object::Enum(3)

Object::Enum - replacement for "if ($foo eq 'bar')"

  use Object::Enum qw(Enum);

  my $color = Enum([ qw(red yellow green) ]);
  # ... later
  if ($color->is_red) {
  # it can't be yellow or green

See Sub::Exporter for ways to customize this module's exports.

An optional shortcut for "Object::Enum->new".

  my $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:

  • unset

    whether this object can be 'unset' (defaults to true)

  • default

    this object's default value is (defaults to undef)

  • values

    an arrayref, listing the object's possible values (at least one required)

  my $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.

The current value as a string (or undef)

Note: don't pass in undef; use the unset method instead.

The possible values for this object

Unset the object's value (set to undef)

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'

Hans Dieter Pearcey, "<hdp at cpan.org>"

Please 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.

You can find documentation for this module with the perldoc command.

    perldoc Object::Enum

You can also look for information at:

  • AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Object-Enum>

  • CPAN Ratings

    <http://cpanratings.perl.org/d/Object-Enum>

  • RT: CPAN's request tracker

    <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-Enum>

  • Search CPAN

    <http://search.cpan.org/dist/Object-Enum>

  • GitHub

    <https://github.com/jmmills/object-enum/>

Copyright 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.

2014-05-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.