http://qs321.pair.com?node_id=559528


in reply to What is the difference between the constant construct in Perl and the Readonly construct in Perl?

Hi,

A key feature (in my view) of Readonly that others haven't mentioned yet is that a Readonly hashref will prevent you from modifying the referenced hash. The constant pragma, in contrast, only prevents you from changing the top-level reference value. The constant will always point to the same hash, but that hash can be modified. Maybe this might change in future, I don't know, but in the meantime I've been bitten by this not-entirely-constant nature of the constant pragma (inadvertently using a "constant" hash as a global variable...). It's fine for scalar and array values, but a bit dodgy for hashes, IMHO.

cheers,
Tim