/usr/share/perl5/App/rdfns.pm is in librdf-ns-perl 20150725-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | package App::rdfns;
use v5.10;
use strict;
use warnings;
use RDF::NS;
our $VERSION = '20150725';
sub new {
bless {}, shift;
}
sub run {
my ($self, @ARGV) = @_;
my $format = '';
return $self->usage if !@ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/;
return $self->version if $ARGV[0] =~ /^(-v|--version)$/;
return $self->dates if $ARGV[0] eq '--dates';
my $ns = RDF::NS->new;
my $sn = $ns->REVERSE;
foreach my $a (@ARGV) {
if ( $a =~ /^([0-9]{8})$/ ) {
$ns = RDF::NS->new($a);
$sn = $ns->REVERSE;
next;
}
if ( $a =~ qr{^https?://} ) {
my $qname = $sn->qname($a);
if ($qname) {
$qname =~ s/:$//;
say $qname;
}
} elsif ( $a =~ /:/ ) {
print map { $ns->URI($_)."\n" } split(/[|, ]+/, $a);
} elsif ( $a =~ s/\.([^.]+)$// ) {
my $f = $1;
if ( $f eq 'prefix' ) {
print map { "$_\n" if defined $_ } map {
$sn->{$_}
} $ns->FORMAT( $format, $a );
next;
} elsif ( $f =~ $RDF::NS::FORMATS ) {
$format = $f;
} else {
print STDERR "Unknown format: $f\n";
}
}
if ( lc($format) eq 'json' ) {
say join ",\n", $ns->FORMAT( $format, $a );
} else {
say $_ for $ns->FORMAT( $format, $a );
}
}
}
sub usage {
print <<'USAGE';
USAGE: rdfns { [YYYYMMDD] ( <prefix[es]>[.format] | prefix:name | URL ) }+
formats: txt, sparql, ttl, n3, xmlns, json, beacon, prefix
options: --help | --version | --dates
examples:
rdfns 20111102 foaf,owl.ttl
rdfns foaf.xmlns foaf.n3
rdfns rdfs:seeAlso
rdfns http://www.w3.org/2003/01/geo/wgs84_pos#
rdfns http://purl.org/dc/elements/1.1/title
rdfns wgs.prefix
USAGE
0;
}
sub version {
print $RDF::NS::VERSION . "\n";
0;
}
sub dates {
my $fh = RDF::NS->new->DATA;
my $date = '';
foreach (<$fh>) {
chomp;
next if /^#/;
my @fields = split "\t", $_;
if ($fields[2] ne $date) {
say $date=$fields[2];
}
}
0;
}
1;
__END__
=head1 NAME
App::rdfns - quickly get common URI namespaces
=head1 SEE ALSO
This module implements the command line client L<rdfns>.
=encoding utf8
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013- by Jakob Voß.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|