Excerpts from Yuri Shtil's message of Tue Aug 18 12:15:03 -0700 2009: > Actually I realized I made a mistake in my question. > I want to be able to make an attribute read only after changing it in > certain places of my code. The reason is that I want to control access > similar to private in C++;
Don't change it to readonly; make the writer private ('_set_foo'). is => 'ro' is just a shortcut for reader => $attribute_name so you would do something like has foo => (is => 'ro', writer => '_set_foo'); An attribute is actually never 'readonly' in some inherent sense -- the methods attached to it generates may allow writing, or may not, but there's no security layer behind those methods stopping you from setting the slot value. hdp.