The current phase of the perl interpreter.

perl ��ゃ�潟�帥����ŝ�帥�勛憜����勉����с�若�冴��

Possible values are:



The PerlInterpreter* is being constructed via perl_construct. This value is mostly there for completeness and for use via the underlying C variable PL_phase. It's not really possible for Perl code to be executed unless construction of the interpreter is finished.

PerlInterpreter* ��� perl_construct ��ф��膀���������障����� �����勐����違�壔�祉�������ï�������с�勉�������������榊�������ŝ�c�⓾����� C 紊��� PL_phase 腟���宴�с�勌戎�����勉��������絖���������⓾����障����� 絎������˨�壔�ゃ�潟�帥����ŝ�帥�勖��膀����絎�篋������ŝ�������� Perl ��潟�若����� 絎�茵���������������壔�с����障��������


This is the global compile-time. That includes, basically, every BEGIN block executed directly or indirectly from during the compile-time of the top-level program.

��������壔�潟�潟����ゃ�������˨�違�㏍�若����˨�с����� ��������壠�堺�㋜����˨����贋・絎�茵���������������������������㋘����˨����㏍�違�í���� ��潟�潟����ゃ�������勰����̹���・������絎�茵���������������⓾�� BEGIN ��с�����

This phase is not called "BEGIN" to avoid confusion with BEGIN-blocks, as those are executed during compile-time of any compilation unit, not just the top-level program. A new, localised compile-time entered at run-time, for example by constructs as eval "use SomeModule" are not global interpreter phases, and therefore aren't reflected by ${^GLOBAL_PHASE}.

BEGIN �����㏍����壔����勖祁箙宴����帥�������������˨�������勉����с�若�冴�勐�������� "BEGIN" ��с� ��������障�����; �����������壠����˨����������㋘����˨����㏍�違�í����с�壔�ŝ�����篁紙����勉�潟�潟����ゃ� ��⓾����������勉�潟�潟����ゃ�˩賢���絎�茵���������障����� 箴������� eval "use SomeModule" ��勉�������˨��絎�茵���������ャ�c�� ��違�������㏍�若�˨����������������潟�潟����ゃ�������壔�違�㏍�若����˨�ŝ�ゃ�潟�帥����ŝ�帥����с�若�冴�с�壔�ŝ����� 緇���c�� ${^GLOBAL_PHASE} �����������������障��������


Execution of any CHECK blocks.

CHECK �����㏍����壔�勐��茵����


Similar to "CHECK", but for INIT-blocks, not CHECK blocks.

"CHECK" ���篌若�⓾����障��������CHECK �����㏍����壔�с�壔�ŝ�� INIT �����㏍����壔��


The main run-time, i.e. the execution of PL_main_root.

��<�ゃ�潟�勐��茵�; ��ゃ�障�� PL_main_root ��勐��茵����


Execution of any END blocks.

END �����㏍����壔�勐��茵����


Global destruction.


Also note that there's no value for UNITCHECK-blocks. That's because those are run for each compilation unit individually, and therefore is not a global interpreter phase.

��障�����UNITCHECK �����㏍����壔�勉�������勐�ゃ�壔�ŝ�����������羈���������⓾�������������� ��ŝ����ŝ����������������壔�潟�潟����ゃ�˨�⓾��������罸���̥�㋜�����絎�茵����������緇���c� ��違�㏍�若����˨�ŝ�ゃ�潟�帥����ŝ�帥����с�若�冴�с�壔�ŝ����������с�����

Not every program has to go through each of the possible phases, but transition from one phase to another can only happen in the order described in the above list.

�����⓾�勉����㏍�違�í������櫝�純�ɱ����⓾�勉����с�若�冴����������ŝ�������違�ŝ����ŝ����������с� ��������障����������������������с�若�冴�����篁���勉����с�若�冴�吾�勛Щ茵���壚��菴違� �����с�勉�粋儀��������障�����

An example of all of the phases Perl code can see:

Perl ��潟�若����勐����⓾�勉����с�若�冴��荀����箴���с��:

    BEGIN { print "compile-time: ${^GLOBAL_PHASE}\n" }

    INIT  { print "init-time: ${^GLOBAL_PHASE}\n" }

    CHECK { print "check-time: ${^GLOBAL_PHASE}\n" }

        package Print::Phase;

        sub new {
            my ($class, $time) = @_;
            return bless \$time, $class;

        sub DESTROY {
            my $self = shift;
            print "$$self: ${^GLOBAL_PHASE}\n";

    print "run-time: ${^GLOBAL_PHASE}\n";

    my $runtime = Print::Phase->new(
        "lexical variables are garbage collected before END"

    END   { print "end-time: ${^GLOBAL_PHASE}\n" }

    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.

�����勐����違�� Perl 5.14.0 ��ц申�����������障��������