forked from yapceurope/perl-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_yml
executable file
·53 lines (46 loc) · 1.64 KB
/
sort_yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl
use strict;
use warnings;
use YAML qw( LoadFile Dump );
my $file = shift || 'conferences.yml' ;
my $confs = LoadFile( $file );
my %seen;
my %cache = map {
$seen{$_->{conf_id}}++;
$_->{begin} =~ /(\d\d|xx).(\d\d|xx).(\d\d\d\d)$/;
$_->{conf_id} => "$3-$2-$1";
} @$confs;
my @dupes = grep { $seen{$_} > 1 } keys %seen;
die "duplicates @dupes" if @dupes;
@$confs = sort { $cache{$b->{conf_id}} cmp $cache{$a->{conf_id}} } @$confs;
open my $fh, '>:utf8', $file or die "Can't open file $file: $!";
print $fh '', << 'HEADER';
# Perl conferences information
# Gathered by Philippe Bruhat (BooK) <book@cpan.org>
# Free to use, don't forget to give credit/link back
# Patches to http://github.com/yapceurope/perl-events/
#
# Fields:
# - act_open: date of opening of the Act conference website
# - act_instance: name of the Act instance hosting the conference website
# - attendees: number of attendees
# - begin: beginning date of the conference
# - cc: country code (iso 3166)
# - city: city name (optional region/state)
# - conf_id: Act-like conference id
# - continent: continent name, in a 5 continents world view
# - cost: hash indexed by price name
# - country: country name
# - end: end date of the conference
# - genre: workshop | hackathon | yapc | osdc
# - languages: languages of the conference list
# - lc: language codes of the conference (iso 639)
# - name: conference name
# - nickname: conference nickname
# - part_of: larger conference this conference was part of
# - status: ok | canceled | unknown
# - theme: theme of the conference
# - type: grassroot | business
# - url: main conference website
HEADER
print $fh Dump( $confs );