develooper Front page | perl.perl5.porters | Postings from October 2003

Re: How to tell if Perl has -DDEBUGGING?

Thread Previous | Thread Next
From:
Steve Hay
Date:
October 24, 2003 09:39
Subject:
Re: How to tell if Perl has -DDEBUGGING?
Message ID:
3F995651.1000507@uk.radan.com
Nicholas Clark wrote:

>On Fri, Oct 24, 2003 at 05:00:30PM +0100, Steve Hay wrote:
>  
>
>>which is all well and good, but some devious miscreant could easily edit 
>>their Config.pm file to lie about whether the Perl has DEBUGGING or not.
>>
>>Is there no way for Perl itself to tell us?
>>
>>The end of the "perl -V" output contains this:
>>
>>   Characteristics of this binary (from libperl):
>>     Compile-time options: DEBUGGING
>>     Built under MSWin32
>>     Compiled at Oct 24 2003 15:50:11
>>
>>That doesn't come from Config.pm.  Instead, as it says, it comes from 
>>Perl (libperl) itself.  That's what I want.  Can I get at *that* 
>>DEBUGGING setting (other than by the obvious and undesirable means of 
>>doing a "perl -V" system call and parsing the output)?
>>    
>>
>
>Not that I'm aware of. However, based on the useful feature that you can
>change $^D at runtime to flip the -DDEBUGGING switches, and a perusal of
>perlrun for something to hijack, try this:
>
>$ perl5.8.0 -le  'sub D {local $^D = 8192; my %a = (1=>2); $^D=8192; (values %a)[0] == 2 ? 0 : 1}; print &D ? "DDEBUGGING" : "not"'
>not
>$ perl5.8.0-g -le  'sub D {local $^D = 8192; my %a = (1=>2); $^D=8192; (values %a)[0] == 2 ? 0 : 1}; print &D ? "DDEBUGGING" : "not"'
>DDEBUGGING
>
Is there any particular reason that you've set $^D=8192 in the middle of 
that one-liner as well as the local $^D=8192 at the start of it?

It seems to work OK for me without the extra $^D=8192 in the middle, but 
I don't know if I'm missing something:

C:\Temp>C:\perl5\bin\perl -le "sub D {local $^D = 8192; my %a = (1=>2); 
(values%a)[0] == 2 ? 0 : 1}; print &D ? 'DEBUGGING' : 'not'"
not

C:\Temp>C:\perl5d\bin\perl -le "sub D {local $^D = 8192; my %a = (1=>2); 
(values %a)[0] == 2 ? 0 : 1}; print &D ? 'DEBUGGING' : 'not'"
DEBUGGING

- Steve


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About