Subject: | Succesful Methods still set $@ |
When used with debug => 0 and while running successfuly, the new() and
get_weather() methods return with $@ set, even when successful. This
causes some other programs, notably Xchat, to think that something is
wrong when it is not.
I am using this program in a midified version (attached) of the
weather.pl script (http://paralox.org/downloads/weather.tar.gz) for
Xchat. Xchat emits error messages even when all is apparently well.
I'm not sure that $@ is a good place to store non-fatal error messages.
If the email address above doesn't work, use bobniederman@speakeasy.net
Subject: | weather.pl |
#!/usr/bin/perl
# Usage: /weather <zipcode>
# Author: epoch @ irc.cyberchat.org
use Weather::Underground;
use Xchat qw(:all);
Xchat::register('weather.pl','1.0');
# Xchat::print"* Weather Script Loaded...";
my $weather1 = sub {
my $weather = Weather::Underground->new(place => $_[1][1], debug => 0 ) or die "Error, could not create new weather object: $@";
$arrayref = $weather->get_weather() or die "Error, calling get_weather() failed: $@\n";
Xchat::print(" Weather Report For: $arrayref->[0]->{place}");
Xchat::print(" Fahrenheit: $arrayref->[0]->{temperature_fahrenheit}");
Xchat::print(" Celsius: $arrayref->[0]->{temperature_celsius}");
Xchat::print(" Humidity: $arrayref->[0]->{humidity}");
Xchat::print(" Conditions: $arrayref->[0]->{conditions}");
# Xchat::print(" Wind: $arrayref->[0]->{wind}");
Xchat::print(" Pressure: $arrayref->[0]->{pressure}");
Xchat::print(" Updated: $arrayref->[0]->{updated}");
return Xchat::EAT_ALL;
};
Xchat::hook_command('weather', $weather1);