The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl

=head1 NAME

oai-listmetadata - list metadataformats in an OAI-PMH archive

=head1 SYNOPSIS

    oai-listmetadata --baseURL=http://preprint.chemweb.com/CPS/OAI

=head1 DESCRIPTION

A command line utility to listing the metadata formats that a OAI-PMH 
repository supports.

=head1 AUTHORS

=over 4 

=item * Ed Summers <ehs@pobox.com>

=back

=cut

use strict;
use Getopt::Long;
use Net::OAI::Harvester;
use Pod::Usage;

my ( $url, $debug ); 

GetOptions(
    'baseURL:s'	=> \$url,
    'debug!'	=> \$debug,
);

if ( !$url ) { 
    pod2usage( { -verbose => 0 } );
}

my $harvester = Net::OAI::Harvester->new( baseURL => $url );
$Net::OAI::Harvester::DEBUG = 1 if $debug;

my $list = $harvester->listMetadataFormats();

if ( $list->errorCode() ) { 
    print STDERR $list->errorString(); 
    exit(1);
}

print "\n",join( "\n", $list->prefixes() ),"\n";