Check::GlobalPhase - Check::GlobalPhase fast XS checker for Perl GlobalPhase
version 0.001
#!perl use strict; use warnings; use Test::More; # just used for illustration purpose use Check::GlobalPhase; INIT { # instead of using a string comparison ok ${^GLOBAL_PHASE} eq 'INIT'; # you can use the boolean helpers # to check if you are in one of the current Perl Phase ok Check::GlobalPhase::in_global_phase_init(); # other helpers ok !Check::GlobalPhase::in_global_phase_construct(); ok !Check::GlobalPhase::in_global_phase_start(); ok !Check::GlobalPhase::in_global_phase_check(); ok !Check::GlobalPhase::in_global_phase_run(); ok !Check::GlobalPhase::in_global_phase_end(); ok !Check::GlobalPhase::in_global_phase_destruct(); } # if you need to check more than one phase at the same time # you can use bitmask like this ok Check::GlobalPhase::current_phase() & ( Check::GlobalPhase::PERL_PHASE_INIT | Check::GlobalPhase::PERL_PHASE_RUN ); # using one ore more of the available constants Check::GlobalPhase::PERL_PHASE_CONSTRUCT; Check::GlobalPhase::PERL_PHASE_START; Check::GlobalPhase::PERL_PHASE_CHECK; Check::GlobalPhase::PERL_PHASE_INIT; Check::GlobalPhase::PERL_PHASE_RUN; Check::GlobalPhase::PERL_PHASE_END; Check::GlobalPhase::PERL_PHASE_DESTRUCT; done_testing;
Check::GlobalPhase provides some fast helpers to check the current Perl Phase. This is avoiding the creation of useless SvPV to perform a string comparison using ${^GLOBAL_PHASE}
SvPV
${^GLOBAL_PHASE}
View ${^GLOBAL_PHASE} from perlvar for more details.
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'CONSTRUCT'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'START'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'CHECK'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'INIT'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'RUN'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'END'
Return a boolean value. True if ${^GLOBAL_PHASE} eq 'DESTRUCT'
You can use this constant to perform some bitmask check with the current Perl_Phase returned from current_phase. (view synopsis)
Nicolas R. <atoomic@cpan.org>
This software is copyright (c) 2019 by cPanel L.L.C.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Check::GlobalPhase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Check::GlobalPhase
CPAN shell
perl -MCPAN -e shell install Check::GlobalPhase
For more information on module installation, please visit the detailed CPAN module installation guide.