Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

use Data::ICal $calendar->add_entry($event) fails

16 views
Skip to first unread message

Erhard Wagner

unread,
Dec 29, 2009, 10:31:32 AM12/29/09
to
Hi,

I try to manipulate iCalendar DATA by my own but

$calendar->add_entry($event); throws an error

<code perl>
#!/usr/bin/perl -w

use strict;

use Date::ICal;
use Data::ICal;
use Data::ICal::Entry::Event;

my $calendar = Data::ICal->new(filename => 'foo.ics');
$calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');
my $event = Data::ICal::Entry::Event->new();
$event->add_properties(
summary => "Subject",
description => "FreeFormText.\\nMore FreeFormText.\\n\\n",
dtstart => Date::ICal->new( epoch => time )->ical,
dtend => Date::ICal->new( epoch => time+3 )->ical,
dtstamp => Date::ICal->new( epoch => time )->ical,
class => "PUBLIC",
organizer => "MAILTO:foo\@bar",
location => "Phone call",
priority => 5,
transp => "OPAQUE",
sequence => 0,
uid => "123",
);
#line 27
$calendar->add_entry($event);
print $calendar->as_string;
__END__
</code>

ERROR:
Can't locate object method "add_entry" via package
"Class::ReturnValue" at ical.pl line 27.

thanks for help

Tad McClellan

unread,
Dec 29, 2009, 12:22:01 PM12/29/09
to
Erhard Wagner <erh.o....@t-online.de> wrote:

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


What is the point of creating that object...


> $calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');


... only to destroy that object on the very next line?

What do you see when you add this below the above line of code?

print $calendar->error_message;

??

I see:

parse failure: BEGIN VCALENDAR... without matching END at ...


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"

Erhard Wagner

unread,
Dec 29, 2009, 1:05:27 PM12/29/09
to
Am 29.12.2009 18:22, schrieb Tad McClellan:
> Erhard Wagner<erh.o....@t-online.de> wrote:
>
>> my $calendar = Data::ICal->new(filename => 'foo.ics');
>
>
> What is the point of creating that object...
>
>
>> $calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');
>
>
> ... only to destroy that object on the very next line?
>
> What do you see when you add this below the above line of code?
>
> print $calendar->error_message;
>
> ??
>
> I see:
>
> parse failure: BEGIN VCALENDAR... without matching END at ...
>
>
I see the same message.

The code I used is a copy of an example given by several man pages in
the net. (http://search.cpan.org/dist/Data-ICal/)

I can't find any additional information or help about this.

Tad McClellan

unread,
Dec 29, 2009, 3:38:34 PM12/29/09
to
Erhard Wagner <erh.o....@t-online.de> wrote:
> Am 29.12.2009 18:22, schrieb Tad McClellan:
>> Erhard Wagner<erh.o....@t-online.de> wrote:
>>
>>> my $calendar = Data::ICal->new(filename => 'foo.ics');
>>
>>
>> What is the point of creating that object...


That was not a rhetorical question.

I was hoping that you would answer it.

Why are you creating that object only to immediately destroy that object?

[ But now it *is* a rhetorical question, as I can see that the answer is
"I do not know why (because I am cargo-culting code)".
]


>>> $calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');

^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^

That is not a complete ICal spec.


>> I see:
>>
>> parse failure: BEGIN VCALENDAR... without matching END at ...
>>
>>
> I see the same message.
>
> The code I used is a copy of an example given by several man pages in
> the net. (http://search.cpan.org/dist/Data-ICal/)


If you want the data to come from a file use

$calendar = Data::ICal->new(filename => 'foo.ics');

If you want to provide the data as a literal string in your program use:

$calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');

> I can't find any additional information or help about this.


The ellipsis (the ...) is META, it is meant that you would replace
that with the rest of a valid ICal spec.

If you just want an empty $calendar, then:

my $calendar = Data::ICal->new();

works without making any error messages.

Erhard Wagner

unread,
Dec 29, 2009, 3:53:42 PM12/29/09
to
Am 29.12.2009 21:38, schrieb Tad McClellan:
> Erhard Wagner<erh.o....@t-online.de> wrote:
>> Am 29.12.2009 18:22, schrieb Tad McClellan:
>>> Erhard Wagner<erh.o....@t-online.de> wrote:
>>>
>>>> my $calendar = Data::ICal->new(filename => 'foo.ics');
>>>
>>>
>>> What is the point of creating that object...
>
>
> That was not a rhetorical question.
>
> I was hoping that you would answer it.

'foo.ics' is an existing calendar.

> Why are you creating that object only to immediately destroy that object?
>
> [ But now it *is* a rhetorical question, as I can see that the answer is
> "I do not know why (because I am cargo-culting code)".
> ]
>
>
>>>> $calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');
> ^^^^^^^^^^^^^^^^^^
> ^^^^^^^^^^^^^^^^^^
>
> That is not a complete ICal spec.
>
>
>>> I see:
>>>
>>> parse failure: BEGIN VCALENDAR... without matching END at ...
>>>
>>>
>> I see the same message.
>>
>> The code I used is a copy of an example given by several man pages in
>> the net. (http://search.cpan.org/dist/Data-ICal/)
>
>
> If you want the data to come from a file use
>
> $calendar = Data::ICal->new(filename => 'foo.ics');
>
> If you want to provide the data as a literal string in your program use:
>
> $calendar = Data::ICal->new(data => 'BEGIN:VCALENDAR...');
>
>
>> I can't find any additional information or help about this.
>
>
> The ellipsis (the ...) is META, it is meant that you would replace
> that with the rest of a valid ICal spec.
>
> If you just want an empty $calendar, then:
>
> my $calendar = Data::ICal->new();
>
> works without making any error messages.
>
>

I found that the following prevents the error:

$calendar = Data::ICal->new( data => 'BEGIN:VCALENDAR...'
, filename => 'foo.ics'
, vcal10 => 0
); # parse from scalar

the default value of vcal10 (true) was the problem.
After this change my test-script works fine.

Thanks for help!

0 new messages