Parsing an ICal file with Perl

I finally almost got it …

Here is a code snippet for parsing and showing pieces of an ICal file :

use strict;
use warnings;

use Data::ICal;
use Data::ICal::DateTime;
use DateTime;

my $cal = Data::ICal->new(filename => 'holidays.ics');

my @events = $cal->events();

foreach my $event (@events) {
        print "summary:", $event->property('summary')->[0]->value, "n";
        print "dtstart:", $event->start, "n";
        print "dtend:", $event->end, "n";
print DateTime->now, "n";

What I want to do ? Drive my home automation events with my Mozilla Calendar !! I’ll soon be there, if I gather enough time to do it !

Some pointers :

  • DateTime perl module : a hell of a lot of computations with dates and times
  • Data::ICal perl modules : for all the parsing stuff
  • Data::ICal::DateTime perl module : to get it to work with DateTime