From 44314a7bd3d95dc98592ed42e4bf832f8542d19f Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Thu, 23 Nov 2006 12:20:09 +0000 Subject: [PATCH] Add -d debug option, and more debug output. --- linux/plan2icalendar | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/linux/plan2icalendar b/linux/plan2icalendar index f128ab0888..ec8bed647e 100755 --- a/linux/plan2icalendar +++ b/linux/plan2icalendar @@ -20,12 +20,12 @@ use Date::ICal; my @events; my %opts; -my $debug = 0; -unless (getopts('if:o:', \%opts)) { +unless (getopts('dif:o:', \%opts)) { usage(); exit 1; } +my $debug = $opts{d} || 0; my $input = $opts{f}; my $output = $opts{o}; @@ -47,6 +47,7 @@ Imports or exports between plan and iCalendar. -i import ical file -f infile read input from 'infile' -o outfile read output from 'outfile' + -d enable debug output EOF } sub read_planfile { @@ -153,25 +154,27 @@ sub read_icalendar { open (ICALENDAR, "<$filename") or die "Unable to read from $filename"; my $oldval = $/; $/ = "\r\n"; + print STDERR "Loading $filename\n" if $debug; while () { - chomp; - if (m/^BEGIN:VEVENT/) { - my %event; - while () { - chomp; - last if (m/END:VEVENT/); - $event{description} = $1 if (m/^DESCRIPTION\s*:\s*(.+)$/); - $event{created} = $1 if (m/^CREATED\s*:\s*(.+)$/); - $event{dtend} = $1 if (m/^DTEND\s*:\s*(.+)$/); - $event{dtstamp} = $1 if (m/^DTSTAMP\s*:\s*(.+)$/); - $event{dtstart} = $1 if (m/^DTSTART\s*:\s*(.+)$/); - $event{last-modified} = $1 if (m/^LAST-MODIFIED\s*:\s*(.+)$/); - $event{sequence} = $1 if (m/^SEQUENCE\s*:\s*(.+)$/); - $event{summary} = $1 if (m/^SUMMARY\s*:\s*(.+)$/); - $event{uid} = $1 if (m/^UID\s*:\s*(.+)$/); - } - push @events, \%event; - } + chomp; + if (m/^BEGIN:VEVENT/) { + my %event; + while () { + chomp; + last if (m/END:VEVENT/); + $event{description} = $1 if (m/^DESCRIPTION\s*:\s*(.+)$/); + $event{created} = $1 if (m/^CREATED\s*:\s*(.+)$/); + $event{dtend} = $1 if (m/^DTEND\s*:\s*(.+)$/); + $event{dtstamp} = $1 if (m/^DTSTAMP\s*:\s*(.+)$/); + $event{dtstart} = $1 if (m/^DTSTART\s*:\s*(.+)$/); + $event{last-modified} = $1 if (m/^LAST-MODIFIED\s*:\s*(.+)$/); + $event{sequence} = $1 if (m/^SEQUENCE\s*:\s*(.+)$/); + $event{summary} = $1 if (m/^SUMMARY\s*:\s*(.+)$/); + $event{uid} = $1 if (m/^UID\s*:\s*(.+)$/); + } + push @events, \%event; + print STDERR "Event pushed\n" if $debug; + } } close (ICALENDAR); $/ = $oldval; -- 2.47.2