![]() |
|
XP is just a number | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
I'm sure your way is more efficient compared to calling a sub all the time, but I would definitely push for "use constant" in this scenario, especially if you're concerned with efficiency Suppose the following is in a file called "debug.pl":
They look pretty much the same, but you should see the output of perl -MO=Deparse debug.pl
There you see that the second option gives you a literal print "bar\n" without needing to evaluate another variable. This is because of a couple of reasons: 1 - the perl compiler is smart enough to optimize away "real" constants... and 2 - *DEBUG = \1 is NOT a "real" constant. (You can always assign on top of *DEBUG if you so choose to). In reply to (lestrrat) Do use 'constant': Re(4): Am I missing something here?
by lestrrat
|
|