worthmine / Text-vCard-Precisely

Read, Write or Edit vCard 3.0 or 4.0 with perl
https://metacpan.org/pod/Text::vCard::Precisely
Other
3 stars 3 forks source link

load_file seems to do nothing? #28

Open michaelof opened 4 years ago

michaelof commented 4 years ago

Hi Yuki,

after being successfully able to WRITE a vcard with your nice modules, I now want to READ them back. To apply changes, finally.

I have the following small script:

#!/usr/bin/perl
#
use strict;
use warnings;
use utf8;
use Data::Dumper;

use Text::vCard::Precisely;

my $vc = Text::vCard::Precisely->load_file('myvcard.vcf');
print Dumper $vc;
=pod
$VAR1 = 'Text::vCard::Precisely';
=cut

print $vc->as_string();
=pod
Can't use string ("Text::vCard::Precisely") as a HASH ref while "strict refs" in use at reader Text::vCard::Precisely::version (defined at /home/michael/perl5/lib/perl5/Text/vCard/Precisely.pm line 11) line 5.
=cut 

which fails, respective output added as pod. myvcard.vcf is a valid v3 vcard, written with as_file before, loads fine e.g. into Nextcloud.

Any hints? Should it work this way? Anything missed by me? Bug?

Regards, Michael

worthmine commented 4 years ago

Hi, thank you for daily reports. Firstly, I am sorry that there is nothing I can help you :(

To tell the truth, I don't know well around this method because it perfectly depends on Text::vFile::asData.

I will reply after I read well the doc about that.

michaelof commented 4 years ago

I've asked in IRC channel #perl for help. This script loads the vfile correctly:

#!/usr/bin/perl
#
use strict;
use warnings;
use utf8;
use Data::Dumper;

use Text::vFile::asData();  
open my $fh, "<", "myvcard.vcf" or die "couldn't open vcf: $!"; 
my $vf = Text::vFile::asData->new({ preserve_params => 1 });  
my $data = $vf->parse($fh)->{'objects'}[0];  
print Dumper $data;

Does this help?

worthmine commented 4 years ago

@michaelof Ha ha, the matter is solved. These constructors I explained so in the PODs were NOT constructors.

Just I did miswrite is the matter.

I'll fix them ASAP.