Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created June 26, 2009 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/136581 to your computer and use it in GitHub Desktop.
Save kyanny/136581 to your computer and use it in GitHub Desktop.
#!/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