
The readonly module (q.v.) is an effective way to create non-modifiable variables. however, it's relatively slow.
the reason it's slow is that is implements the read-only-ness of variables via tied objects. this mechanism is inherently slow. perl simply has to do a lot of work under the hood to make tied variables work.
this module corrects the speed problem, at least with respect to scalar variables. when readonly::xs is installed, readonly uses it to access the internals of scalar variables. instead of creating a scalar variable object and tying it, readonly simply flips the svreadonly bit in the scalar's flags structure.