#!/usr/bin/perl -w
# This perl script will do a quick and dirty parse from
# outlook vcal to evolution ical format
# Last Update:Thu Feb 05 11:49:59 CST 2004
# Michael Palmer <mpalmer at mcleancargo.com>
use strict;

my $file = $ARGV[0] or die "No filename specified";
   die if (!-e $file);
my $newfile = $file;
   $newfile =~ s/\..*$/\.ics/;

open(VCSFILE,$file)
	or die "Error opening '$file': $!\n";
	my @vcs = <VCSFILE>;
close(VCSFILE);

open(ICSFILE,">".$newfile)
	or die "Error opening '$file': $!\n";
	foreach(@vcs) {
		s/^(\w+);[\w\=\-]+:/$1:/; s/^(\w+:)\s/$1/; s/^End/END/;
		s/=0D/\\n/g; s/=0A//g; s/\015\012/\n/g; s/,//g;
		print ICSFILE if (!/^ORGAN|PRODI/);
	}
close(ICSFILE);
