File: cyclical_thing.pl

package info (click to toggle)
libhtml-html5-microdata-parser-perl 0.100-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 400 kB
  • sloc: perl: 4,036; makefile: 7; sh: 1
file content (27 lines) | stat: -rw-r--r-- 751 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl

use 5.010;
use strict;
use warnings;
use lib "lib";
use HTML::HTML5::Microdata::Parser;
use RDF::TrineShortcuts;

my $h = <<HTML;

<span itemscope itemid="http://example.com/throwaway/a" itemtype="http://example.com/type">
	Turtle: <a itemprop="http://example.com/turtle" href="http://example.com/throwaway/b">b</a> 
	<span itemscope itemid="http://example.com/throwaway/b" itemtype="http://example.com/type">
		Turtle: <a itemprop="http://example.com/turtle" href="http://example.com/throwaway/a">a</a>
	</span>
</span>

HTML

my $p = HTML::HTML5::Microdata::Parser->new($h, 'http://example.com/');
$p->set_callbacks({pretriple_resource=>'print',pretriple_literal=>'print'});
$p->consume;

print rdf_string($p->graph, 'ntriples');