Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: using constants to trigger debug code

by Belgarion (Chaplain)
on Jun 04, 2004 at 19:43 UTC ( [id://361172]=note: print w/replies, xml ) Need Help??


in reply to using constants to trigger debug code

If the compiler can determine at compile time that an expression will never be evaluated, it will remove the code. For example:

use strict; use warnings; print "Hello world" if 0; exit 1 if 0; exit 0;

looks like this to the Perl compiler:

$ perl -MO=Deparse /tmp/compile.pl use warnings; use strict 'refs'; '???'; '???'; exit 0;

The two .. if 0; lines are turned into void strings which take basically no time to evaluate.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://361172]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found