my $env_level = $ENV{PERL_DESTRUCT_LEVEL};
if (defined $env_level) {
- $env_level = do {
- no warnings 'numeric';
- int $env_level;
- };
+ no warnings 'numeric';
+ $env_level = int $env_level;
+ }
- my $is_debugging = is_debugging_perl();
- if ($is_debugging) {
- _diag("Global destruction level $env_level set by PERL_DESTRUCT_LEVEL (debugging perl)");
+ my $is_debugging = is_debugging_perl();
+ if ($is_debugging) {
+ if (defined $env_level) {
+ _diag("Global destruction level $env_level set by PERL_DESTRUCT_LEVEL (environment)");
return ($env_level >= $level) ? 1 : 0;
} else {
- _diag("PERL_DESTRUCT_LEVEL is set to $env_level, but this perl doesn't seem to have debugging enabled, ignoring");
+ $ENV{PERL_DESTRUCT_LEVEL} = $level;
+ _diag("Global destruction level $level set by PERL_DESTRUCT_LEVEL (forced)");
+ return 1;
}
+ } elsif (defined $env_level) {
+ _diag("PERL_DESTRUCT_LEVEL is set to $env_level, but this perl doesn't seem to have debugging enabled, ignoring");
}
my $has_perl_destruct_level = do {