[Omaha.pm] silly warnings

Sterling Hanenkamp sterling at hanenkamp.com
Tue Dec 16 18:41:44 PST 2008


On Tue, Dec 16, 2008 at 5:25 PM, Jay Hannah <jhannah at omnihotels.com> wrote:

>  Laugh... Can I complain about too-noisy warnings forcing me to clutter my
> code again? Or am I already over quota?  -laugh-
>
> Original code:
>
>    use warnings;
>    ...
>    next if ($audit->{$date}->{$hotel} > 0);
> Warning:
>
>    Use of uninitialized value in numeric gt (>) at extract_launcher.pl line
> 192.
> So now my code says this:
>
>    next if ($audit->{$date} && $audit->{$date}->{$hotel} &&
> $audit->{$date}->{$hotel} > 0);
> Sigh...   :)
>

I usually prefer:

next if ($audit->{$date}{$hotel} || 0) > 0;

or:

$audit->{$date}{$hotel} ||= 0;
next if $audit->{$date}{$hotel} > 0;

Cheers,
Sterling



>
> j
>
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20081216/ea37df1b/attachment.html>


More information about the Omaha-pm mailing list