perl
view release on metacpan or search on metacpan
pod/perlvar.pod view on Meta::CPAN
our $destruct = Print::Phase->new(
"package variables are garbage collected after END"
);
This will print out
compile-time: START
check-time: CHECK
init-time: INIT
run-time: RUN
lexical variables are garbage collected before END: RUN
end-time: END
package variables are garbage collected after END: DESTRUCT
This variable was added in Perl 5.14.0.
=item $^H
X<$^H>
WARNING: This variable is strictly for
internal use only. Its availability,
behavior, and contents are subject to change without notice.
This variable contains compile-time hints for the Perl interpreter. At the
end of compilation of a BLOCK the value of this variable is restored to the
value when the interpreter started to compile the BLOCK.
Each time a statement completes being compiled, the current value of
C<$^H> is stored with that statement, and can later be retrieved via
C<(caller($level))[8]>. See L<perlfunc/caller EXPR>.
When perl begins to parse any block construct that provides a lexical scope
(e.g., eval body, required file, subroutine body, loop body, or conditional
block), the existing value of C<$^H> is saved, but its value is left unchanged.
When the compilation of the block is completed, it regains the saved value.
Between the points where its value is saved and restored, code that
executes within BEGIN blocks is free to change the value of C<$^H>.
This behavior provides the semantic of lexical scoping, and is used in,
for instance, the C<use strict> pragma.
The contents should be an integer; different bits of it are used for
different pragmatic flags. Here's an example:
sub add_100 { $^H |= 0x100 }
sub foo {
BEGIN { add_100() }
bar->baz($boon);
}
Consider what happens during execution of the BEGIN block. At this point
the BEGIN block has already been compiled, but the body of C<foo()> is still
being compiled. The new value of C<$^H>
will therefore be visible only while
the body of C<foo()> is being compiled.
Substitution of C<BEGIN { add_100() }> block with:
BEGIN { require strict; strict->import('vars') }
demonstrates how C<use strict 'vars'> is implemented. Here's a conditional
version of the same lexical pragma:
BEGIN {
require strict; strict->import('vars') if $condition
}
This variable was added in Perl 5.003.
=item %^H
X<%^H>
The C<%^H> hash provides the same scoping semantics as L<C<$^H>|/$^H>. This
makes it useful for implementing lexically scoped pragmas. See L<perlpragma>.
All the entries are stringified when accessed at runtime, so only simple values
can be accommodated. This means no references to objects, for example.
Each time a statement completes being compiled, the current value of
C<%^H> is stored with that statement, and can later be retrieved via
C<(caller($level))[10]>. See L<perlfunc/caller EXPR>.
When putting items into C<%^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
C<Foo::Bar> should use keys such as C<Foo::Bar/baz>.
This variable was added in Perl v5.6.0.
=item ${^OPEN}
X<${^OPEN}>
An internal variable used by L<PerlIO>. A string in two parts, separated
by a C<\0> byte, the first part describes the input layers, the second
part describes the output layers.
This is the mechanism that applies the lexical effects of the L<open>
pragma, and the main program scope effects of the C<io> or C<D> options
for the L<-C command-line switch|perlrun/-C [I<numberE<sol>list>]> and
L<PERL_UNICODE environment variable|perlrun/PERL_UNICODE>.
The functions C<accept()>, C<open()>, C<pipe()>, C<readpipe()> (as well
as the related C<qx> and C<`STRING`> operators), C<socket()>,
C<socketpair()>, and C<sysopen()> are affected by the lexical value of
this variable. The implicit L</ARGV> handle opened by C<readline()> (or
the related C<< <> >> (diamond) and C<<< <<>> >>> (double diamond)
operators) on passed filenames is
also affected (but not if it opens C<STDIN>). If this variable is not
set, these functions will set the default layers as described in
L<PerlIO/Defaults and how to override them>.
C<open()> ignores this variable (and the default layers) when called with
3 arguments and explicit layers are specified. Indirect calls to these
functions via modules like L<IO::Handle> are not affected as they occur
in a different lexical scope. Directory handles such as opened by
C<opendir()> are not currently affected.
This variable was added in Perl v5.8.0.
=item $PERLDB
=item $^P
X<$^P> X<$PERLDB>
The internal variable for debugging support. The meanings of the
( run in 4.743 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )