Skip Menu |

This queue is for tickets about the Weather-Underground CPAN distribution.

Report information
The Basics
Id: 11816
Status: new
Priority: 0/
Queue: Weather-Underground

People
Owner: Nobody in particular
Requestors: jason [...] axley.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 2.14
  • 2.20
Fixed in: (no value)



Subject: Use of uninitialized value in length at /usr/local/share/perl/5.8.4/Weather/Underground.pm line 810.
I'm using Weather::Underground indirectly on my Movable Type blog via the MT-WeatherUnderground movabletype module that makes variables available from data returned by Weather::Underground. However, if one or both of the windchill variables ends up being null due to the data returned from wunderground.com, I get these annoying warnings: www-data@void:~/blog/bin$ ./mt-rebuild.pl -mode="index" -blog_id="1" -template="Main Index" Use of uninitialized value in length at /usr/local/share/perl/5.8.4/Weather/Underground.pm line 810. Use of uninitialized value in length at /usr/local/share/perl/5.8.4/Weather/Underground.pm line 810. Use of uninitialized value in length at /usr/local/share/perl/5.8.4/Weather/Underground.pm line 810. Use of uninitialized value in length at /usr/local/share/perl/5.8.4/Weather/Underground.pm line 810. I'm not sure if perhaps there has been a change on the wunderground.com site that should result in a change to the regex statements in this block or not, but a fix to suppress the messages is as follows. To suppress these messages, at line 810 of version 2.20 of Weather/Underground.pm, you can wrap the length() statements that end up working on undefined windchill variables in some cases (at least mine, via movable type weather/underground module) to check first that one of the windchill variables is at least defined. The existing code will then ensure that both are defined after this block. # fix to suppress warnings "Use of uninitialized value in length..." if (defined($windchill_celsius) || defined($windchill_fahrenheit)){ if (!length($windchill_celsius) && length($windchill_fahrenheit)) { $windchill_celsius = ($windchill_fahrenheit - 32) / 1.8; } elsif (!length($windchill_fahrenheit) && length($windchill_celsius)) { $windchill_fahrenheit = ($windchill_celsius * 1.8) + 32; } } Regards, -J