package VCalendar; # VCalendar - by James Powell use strict; use vars qw($VERSION); $VERSION = "0.01"; # 21st May 2002 sub new { my $class = shift; my $self = bless {}, $class; my $params = shift; $self->{params} = $params; $self; } sub parse { my $self = shift; my $filename = $self->{params}->{filename}; die unless (-f $filename); my @lines; open(FILE, $filename); while () { s/\r\n$//; push @lines, $_; } close(FILE); my %vcal; my $id; foreach (@lines) { # very quick and dirty if (/^UID\:(.*)$/) { $id = $1; } elsif (/^DTSTART:(.*)$/) { $vcal{$id}->{start} = $1; } elsif (/^DTEND:(.*)$/) { $vcal{$id}->{end} = $1; } elsif (/^SUMMARY:(.*)$/) { $vcal{$id}->{summary} = $1; } # else { print 'arse'; } } $self->{vcal} = \%vcal; } 1;