From 6bbe2df38ad465ad0151c07397d7d85bf0e841dc Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 17 May 2013 21:07:38 +0100 Subject: rough template for output --- forecast-file.pl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/forecast-file.pl b/forecast-file.pl index 950b7e0..990dfa9 100644 --- a/forecast-file.pl +++ b/forecast-file.pl @@ -4,15 +4,20 @@ use warnings; use 5.014; use WebService::ForecastIo::Response; use Path::Class; -use Data::Printer; +use Template; my $res = WebService::ForecastIo::Response->new(file($ARGV[0])->slurp); -p $res; +my $t = Template->new; +$t->process(\*DATA,{f=>$res}) + or die $t->error; -my $hourly_summary_spans = $res->hourly->spans_by_string('summary'); +__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 %] -p $hourly_summary_spans; +[% 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 %] -my $hourly_temp_spans = $res->hourly->spans_by_number('temperature',1); - -p $hourly_temp_spans; -- cgit v1.2.3