The %^H
hash provides the same scoping semantic as $^H
. This makes it useful for implementation of lexically scoped pragmas. See perlpragma. All the entries are stringified when accessed at runtime, so only simple values can be accommodated. This means no pointers to objects, for example.
Each time a statement completes being compiled, the current value of %^H
is stored with that statement, and can later be retrieved via (caller($level))[10]
.
When putting items into %^H
, in order to avoid conflicting with other users of the hash there is a convention regarding which keys to use. A module should use only keys that begin with the module's name (the name of its main package) and a "/" character. For example, a module Foo::Bar
should use keys such as Foo::Bar/baz
.
This variable was added in Perl v5.6.0.