Turtle::Writer - Write RDF/Turtle documents without non-core package dependencies
version 0.003
use Turtle::Writer; say turtle_statement( "<$uri>", "a" => "<http://purl.org/ontology/bibo/Document>", "dc:creator" => { # plain literals are escaped "" => [ "Terry Winograd", "Fernando Flores" ] }, "dc:date" => { "xs:gYear" => "1987" }, # typed literal "dc:title" => { en => "Understanding Computers and Cognition" }, "dc:description" => undef, # will be ignored );
Turtle::Writer is a lightweight helper module for Perl programs that write RDF data in Turtle syntax. No non-core packages are required. Before directly writing RDF/Turtle by hand, have a look at this module. Before using this module, have a look at RDF::Trine::Serializer::Turtle which provides a full featured serializer for RDF data in Turtle syntax.
By default this module exports four methods: turtle_statement, turtle_literal, turtle_literal_list, and turtle_uri. This methods may be handy to directly create serialized RDF from other forms of structured data. Literal values are escaped and undef is ignored, among other features.
turtle_statement
turtle_literal
turtle_literal_list
turtle_uri
undef
Returns a (set of) RDF statements in Turtle syntax. Subject and predicate parameters must be strings. Object parameters must either be strings or arrays of strings. This function strips undefined values and empty strings, but it does not further check or validate parameter values.
Returns a literal string escaped in Turtle syntax. You can optionally provide either a language or a full datatype URI (but their values are not validated). Returns the empty string instead of a Turtle value, if $string is undef or the empty string.
$string
Returns a list of literal strings in Turtle syntax.
Returns an URI in Turtle syntax, that is "<$uri>". Returns the empty string, if $uri is undef, but <> if $uri is the empty string. In most cases you better directly write "<$uri>".
"<$uri>"
$uri
<>
Jakob Voss
This software is copyright (c) 2013 by Jakob Voss.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Turtle::Writer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Turtle::Writer
CPAN shell
perl -MCPAN -e shell install Turtle::Writer
For more information on module installation, please visit the detailed CPAN module installation guide.