Created
June 26, 2009 16:19
-
-
Save kyanny/136581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Getopt::Long::Descriptive; | |
use WebService::Simple; | |
use Encode; | |
use Term::Encoding qw(term_encoding); | |
my $base_url = 'http://weather.livedoor.com/forecast/webservice/rest/v1'; | |
my $format = 'Usage: %c %o'; | |
my @opts = ( | |
['help' => 'print this message'], | |
['city=i' => 'city id', { | |
required => 1, | |
}], | |
['day=s' => '[today|tomorrow|dayaftertomorrow]', { | |
default => 'today', | |
}], | |
); | |
my ($opts, $usage) = describe_options($format, @opts); | |
$usage->die if $opts->{help}; | |
my $service = WebService::Simple->new( | |
base_url => $base_url, | |
); | |
my $response = $service->get($opts); | |
my $obj = $response->parse_response; | |
print encode(term_encoding, $obj->{description}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment