#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;
use WebService::ForecastIo::Response;
use Path::Class;
use Template;

my $res = WebService::ForecastIo::Response->new(file($ARGV[0])->slurp);
my $t = Template->new;
$t->process(\*DATA,{f=>$res})
    or die $t->error;

__DATA__
[% MACRO dtspan BLOCK -%]
<[% x.start_time.strftime('%H:%M%z') %] - [%x.stop_time.strftime('%H:%M%z') %]> [% x.value %]
[%- END -%]
Currently: [% f.currently.summary %] [% f.currently.temperature %]°
[% f.hourly.summary %]

[% FOREACH x IN f.hourly.spans_by_string('summary'); dtspan(x=x); ' '; END %]
[% FOREACH x IN f.hourly.spans_by_number('temperature',2); dtspan(x=x); ' '; END %]

