The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/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;
    }
    my $ns = RDF::NS->new($version);
	if ( $a =~ /:/ ) {
    	print map { $ns->URI($_)."\n" } split(/[|, ]+/, $a);
    } elsif ( $a =~ s/\.([^.]+)$// ) {
        my $f = $1;
        if ( $f =~ $RDF::NS::FORMATS ) {
            $format = $f;
        } else {
            print STDERR "Unknown format: $f\n";
        }
    }
    print map {"$_\n"} $ns->FORMAT( $format, $a );
}



=pod

=head1 NAME

rdfns - quickly get common URI namespaces

=head1 VERSION

version 20120917

=head1 AUTHOR

Jakob Voss

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 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] | prefix:name ) }+

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