http://www.perlmonks.org?node_id=384842


in reply to Re: use fields; # damnit
in thread use fields; # damnit

Hell yeah stvn you can use fields functionality without the fields pragma.

Set up your object around an array instead of a hash, define a series of constants with the field names, and there you are.

I even set up a shortcut module that maps field names to small integers for this purpose (sort of like the "enum" statement in C)

TipJar::fields

see also: enum::fields which is oriented for OO inheritance but which doesn't provide accessors.

  • Comment on fields-like module to facilitate arrayref objects