NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
where "use warnings" burns (Score:2)
My guess is that sometimes, $country is undef. And because it might be, the author writes horribly perverted code just to avoid getting an irrelevant warning message. This is the downside of warnings.
And given that, I'd have written this code as:
$country = $country eq 'gbr' ? '' : uc $country;See how much clearer it is when you stop worrying about stupid warnings? Don't be pedantic about warnings. Stop using them when they make your code look ugly. (/end rant).Re:where “use warnings” burns (Score:1)
If it’s really just undef, then an
or ''in the appropriate spot would suffice – no need for convolution.That said, almost all my code starts like so:
Re: (Score:1)
Re:where “use warnings” burns (Score:2)
Sometimes you refer to a variable in another file:
That snippet will prevent a DOS on your server from folks repeatedly uploading files. However, it's probably only in your code once and warnings will issue a warning about it which you can disable with no warnings 'once'.
It's designed, however, for cases where you declare something and never use it again. That's probably cruft that you don't actually want in your code (or worse, you declare something but refer to it by the wrong name later).
Reply to This
Parent