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
> 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/"
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.
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.
'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!