Debian Codegraph @

bin/vcard2rdf

raw
1 #!/usr/bin/perl
2
3 use strict;
4
5 BEGIN
6 {
7 print STDERR "Reading vCard input from STDIN.\n"
8 unless @ARGV;
9 }
10
11 use RDF::vCard;
12 use RDF::Trine;
13
14 my $importer = RDF::vCard::Importer->new;
15
16 unless (@ARGV)
17 {
18 my ($lang) = split /\./, $ENV{LANG};
19 $lang =~ s/_/-/g;
20
21 local $/ = undef;
22 my $input = <>;
23
24 $importer->import_string($input, lang => $lang);
25 }
26
27 while (my $input = shift @ARGV)
28 {
29 if ($input =~ /^(ftp|http|https|file):/i)
30 {
31 $importer->import_url($input);
32 }
33 else
34 {
35 $importer->import_file($input);
36 }
37 }
38
39 my $ser = RDF::Trine::Serializer::Turtle->new(
40 namespaces => {
41 v => 'http://www.w3.org/2006/vcard/ns#',
42 vx => 'http://buzzword.org.uk/rdf/vcardx#',
43 },
44 );
45 print $ser->serialize_model_to_string($importer->model);