Perldoc Search: "%^H" perl-5.20.1

search official POD

4 PODs, 11 LINEs found.
104 :     User pragmata store their state by writing to the magical hash "%^H", hence these two routines manipulate it. The state information in "%^H" is stored in the optree, and can be retrieved read-only at runtime with "caller()", at index 10 of the list of returned results. In the example pragma, retrieval is encapsulated into the routine "in_effect()", which takes as parameter the number of call frames to go up to find the value of the pragma in the user's script. This uses "caller()" to determine the value of $^H{"myint/in_effect"} when each line of the user's script was called, and therefore provide the correct semantics in the subroutine implementing the overloaded addition.
107 :     There is only a single "%^H", but arbitrarily many modules that want to use its scoping semantics. To avoid stepping on each other's toes, they need to be sure to use different keys in the hash. It is therefore conventional for a module to use only keys that begin with the module's name (the name of its main package) and a "/" character. After this module-identifying prefix, the rest of the key is entirely up to the module: it may include any characters whatsoever. For example, a module "Foo::Bar" should use keys such as "Foo::Bar/baz" and "Foo::Bar/$%/_!". Modules following this convention all play nicely with each other.
109 :     The Perl core uses a handful of keys in "%^H" which do not follow this convention, because they predate it. Keys that follow the convention won't conflict with the core's historical keys.
112 :     The optree is shared between threads. This means there is a possibility that the optree will outlive the particular thread (and therefore the interpreter instance) that created it, so true Perl scalars cannot be stored in the optree. Instead a compact form is used, which can only store values that are integers (signed and unsigned), strings or "undef" - references and floating point values are stringified. If you need to store multiple values or complex structures, you should serialise them, for example with "pack". The deletion of a hash key from "%^H" is recorded, and as ever can be distinguished from the existence of a key with value "undef" with "exists".
768 :      H  PERL_MAGIC_hints          vtbl_hints     %^H hash
769 :      h  PERL_MAGIC_hintselem      vtbl_hintselem %^H hash element
1296 :     Once registered, there is no mechanism to switch these hooks off, so if that is necessary you will need to do this yourself. An entry in "%^H" is probably the best way, so the effect is lexically scoped; however it is also possible to use the "BhkDISABLE" and "BhkENABLE" macros to temporarily switch entries on and off. You should also be aware that generally speaking at least one scope will have opened before your extension is loaded, so you will see some "pre/post_end" pairs that didn't have a matching "start".
885 :             The current set of warning checks enabled by the "use warnings" pragma. It has the same scoping as the $^H and "%^H" variables. The exact values are considered internal to the warnings pragma and may change between versions of Perl.
1065 :     %^H     The "%^H" hash provides the same scoping semantic as $^H. This makes it useful for implementation of lexically scoped pragmas. See perlpragma.
1067 :             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".
317 :         $hinthash is a reference to a hash containing the value of "%^H" when the caller was compiled, or "undef" if "%^H" was empty. Do not modify the values of this hash, as they are the actual values stored in the optree.
<< Back to Perldoc Search