TipJar::fields - generate constants and accessors for array-based objects
package foobarbazobj; use TipJar::fields qw/foo bar baz/; sub new{ shift; bless [@_];}; sub foobaz {my $obj = shift; "$$obj[foo]$obj->[baz]"}; # like C ENUM package main; $fbb = new foobarbazobj qw/uno dos tres/; print $fbb->getfoo(); #prints 'uno' print $fbb->setfoo(700); #prints '700' print $fbb->foobaz(); #prints '700tres'
Sugar to create named fields for accessing arrays, just like ENUM statements in the C programming language. Also goes ahead and creates get and set accessors.
exports zero through however many fields there are, as constant functions, like C ENUM. Also get* and set* accessors for each named field, assuming a reference-to-array object structure.
David Nicol <davidnico@cpan.org> released April 2003 GPL/AL.
fields.
To install TipJar::fields, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TipJar::fields
CPAN shell
perl -MCPAN -e shell install TipJar::fields
For more information on module installation, please visit the detailed CPAN module installation guide.