Well, there was an interesting side effect of parsing my web logs to identify all the places where I'm throwing warnings.
I've got a relative count of how many times the code is being called. Of course, it is only the code that causes warnings that is being counted...
Anyways, this is my most troublesome snippet, accounting for 80 percent of the current warnings.
$form
.= $args->{'hidden'};
$form.= '</form>';
This code builds forms, and has an optional parameter for hidden fields. If there are any hidden fields, they are added right before we close off the form.
It seems a bit much to have to say
$form
.= $args->{'hidden'} if $args->{'hidden'};
When the original code "Does The Right Thing".
Also, 100% of the errors have to do with string concatenation, or comparison operators where I expect that values may be 'undef'.
So... I'm about to spend a lot of time eleminating warnings that are "harmless". Because, even with all my bitching... I know that there will be a payoff... eventually.
Re: cheap profiler (Score:1)
as
If the value of $args{'hidden'} evaluates to false, "" is used instead, and the undef value isn't used for concatenation.
// instead of || ) operator will take care of this in Perl 5.10 (right?)
But note that 0 evaluates to false, so if you expect that as a legit value of $args{'hidden'}, this won't work.
The new defined-or (
Re: cheap profiler (Score:1)
Hm... now that you mention it, mine won't either if the string is '0'.
It isn't a problem in this specific instance... but I may need to actually use 'exists' on the value as a more 'generic' solution.
Re: cheap profiler (Score:1)
No such thing as a harmless warning. (Score:2)
Classic mistake: Some of my code expects undef values so I ignore uninit warnings.
Problem is the rest of your code doesn't expect undef warnings, in those spots getting an undef indicates a possible mistake. By ignoring uninit warnings for one part of the code you ignore problems in the rest. If a certain part of your code expects undefs write it so it handles them quietly
Re:No such thing as a harmless warning. (Score:1)
Actually, I am not ignoring any warnings. I added the use warnings pragma and it did what it was supposed to do... flagged possible problems.
Then, I looked at each and every case and saw that they were all the same class of errors (concatenation of undefined variables or comparison with undefined data) and inspected each and every one and determined that none of them was a bug causing issue.
Classic mistake: This warning i