Last active
August 29, 2015 14:01
-
-
Save bessarabov/ff4ed04debe9a46890c0 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/perl | |
use strict; | |
use warnings FATAL => 'all'; | |
use feature 'say'; | |
use utf8; | |
use open qw(:std :utf8); | |
use DDP; | |
use Carp; | |
use YAML; | |
use LWP::Simple; | |
use Perl6::Form; | |
sub date2ymd { | |
my ($d) = @_; | |
my ($mm, $dd, $yyyy) = $d =~ m|(\d{2})/(\d{2})/(\d{4})|a; | |
my $date = "$yyyy-$mm-$dd"; | |
return $date; | |
} | |
sub main { | |
my $yml = LWP::Simple::get( 'http://yapc.eu/conferences.yml' ); | |
my $data = YAML::Load( $yml ); | |
my @russia_events = grep { | |
($_->{country} eq 'Russia') | |
and ($_->{genre} eq 'yapc') | |
} @{$data}; | |
my $p = '{<<<<<<<<<<<<<<<<}'; | |
my $format = "$p "x5; | |
foreach my $el (sort { date2ymd($a->{begin}) cmp date2ymd($b->{begin})} @russia_events) { | |
print form $format, | |
date2ymd($el->{begin}), | |
$el->{conf_id}, | |
$el->{city} // '', | |
$el->{name} // '', | |
$el->{nickname} // '', | |
; | |
} | |
say '#END'; | |
} | |
main(); | |
__END__ | |
output: | |
2008-17-05 yr2008 Moscow YAPC Russia May Perl | |
2009-16-05 yr2009 Moscow YAPC Russia May Perl - 2 | |
#END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment