Skip to end of metadata
Go to start of metadata


We always disable this policy. The reason is that constants are more resourceful than ReadOnly implemented variables.

The perl interpreter does a good job of optimizing out code, which should not be run, so for example a debug flag implemented as a constant does actually mean that debugging code does not weigh down execution on production if set to a false value.

An example:

B::Terse can show us how the debug section is optimized away:

DEBUG enabled
DEBUG disabled

The same two cases, implemented using ReadOnly.
DEBUG enabled
DEBUG disabled

As you can see the version using proper constants is producing a lot shorter with DEBUG enabled output that the ones with DEBUG disabled or implemented using Readonly.

See also: Explanation on PerlMonks.