On Wed, May 21, 2008 at 4:49 PM, Sartak <[EMAIL PROTECTED]> wrote: > On 5/21/08, Bernardo Rechea <[EMAIL PROTECTED]> wrote: > > Hi Bernardo, > > > I wanted a constant attribute, i.e., one that is read-only and not > settable > > at construction time. > > Does it have to be a full attribute? It could just be a method that > returns a constant. I often have this in my classes: > > package Parent; > use constant needs_trinket => 0; > > package Child; > use constant needs_trinket => 1;
which can also be written: sub needs_trinket () { 0 } and sub needs_trinket () { 1 } perl optimizes things with empty prototypes that return a constant. -Chris