#!/usr/bin/perl
#ABSTRACT: quickly get common URI namespaces
#PODNAME: rdfns

use strict;
use warnings;

use RDF::NS;
my $format = 'txt';
my $version = 'any';

if (!@ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/) {
     print <DATA>;
     exit;
}

foreach my $a (@ARGV) {
    if ( $a =~ /^(\d{8})$/ ) {
        $version = $a;
        next;
    }
    if ( $a =~ s/\.([^.]+)$// ) {
        my $f = $1;
        if ( $f =~ $RDF::NS::FORMATS ) {
            $format = $f;
        } else {
            print STDERR "Unknown format: $f\n";
        }
    }
    print map {"$_\n"} RDF::NS->new($version)->FORMAT( $format, $a );
}



=pod

=head1 NAME

rdfns - quickly get common URI namespaces

=head1 VERSION

version 20111124

=head1 AUTHOR

Jakob Voss

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__DATA__
USAGE: rdfns { [YYYYMMDD] <prefix[es]>[.format] }+

  formats: txt, sparql, ttl, n3, xmlns
 
  examples:
    rdfns 20111102 foaf,owl.ttl
    rdfns foaf.xmlns foaf.n3

