Last active
January 12, 2017 23:14
-
-
Save paveljurca/76a96e7689a0f4802175f9d3085b72e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
use v5.10; | |
use strict; | |
use warnings; | |
use open qw/:std :utf8/; | |
use JSON::PP; | |
# API call example | |
# http://api.rozhlas.cz/data/v2/schedule/day/2017/01/05/vltava/brief.json?callback=jQuery18204554739051964134_1484244887343&_=1484244901325 | |
# *.json | |
my @dny = @ARGV; | |
for (sort @dny) { | |
@ARGV = $_; | |
# skip the first line | |
# // data wrapped in a function call | |
<>; | |
# print JSON::PP->new->pretty->encode( decode_json(substr(<>,0,-3)) ); | |
my @porady; | |
# remove last 3 characters | |
# // data wrapped in a function call | |
for my $porad (@{ decode_json( substr(<>, 0, -3) )->{data} }) { | |
# 2016-12-29T00:00:14+01:00 | |
my $hodina = substr((split("T", $porad->{since}))[1], 0, 2); | |
# between 10 p.m. and 4 a.m. | |
if ($hodina < 4 or $hodina > 21) { | |
push @porady, qq($porad->{since} $porad->{title}); | |
} | |
} | |
say join "\n", @porady; | |
# wait | |
<STDIN>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment