|go ahead... be a heretic|
How to make warnings disappearby Dominus (Parson)
|on Dec 15, 2000 at 07:47 UTC||Need Help??|
In a recent article at www.perl.com, I showed some code that looked like this:
The code was a joke, and I was rather irritated when people write to me to 'correct' it.
Today I got mail from someone who complained that the string "nosehair" generated a 'Useless use of constant in void context' warning under -w, and suggested that I change it to 1 instead. I thought this was a little silly, because you should not have to turn on -w to know that "nosehair" is a bad idea.
One of the big problems with -w is that some people have it wired to a toggle switch and when they turn on -w they disable their brains at the same time.
Anyway, I suggested that if this guy's only problem with "nosehair" was that it generated a warning under -w, he could make the warning go away with the following change:
That's the obfuscation. The puzzle is, why does changing the string make the warning go away?
I will reveal the answer in a couple of days; or you can find it on page 321 of the pink camel book.
(Please don't post spoilers, especially if you were hanging around when I explained it in the chatbox this afternoon. Also if you are Randal, then we already know that you know the answer, since you are an author of the pink camel book.)