+++ /dev/null
-#!/usr/bin/perl
-
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if 0; # not running under some shell
-# This program is part of da_reference, and is released under the
-# terms of the GPL version 2, or any later version, at your
-# option. See the file README and COPYING for more information.
-# Copyright 2004 by Don Armstrong <don@donarmstrong.com>.
-# $Id: get_reference 45 2013-09-10 18:05:31Z don $
-
-
-use warnings;
-use strict;
-
-
-use Getopt::Long;
-use Reference;
-use Pod::Usage;
-
-=head1 NAME
-
-get_reference - Retrieve a reference from somewhere and output the
-formatted reference to STDOUT.
-
-=head1 SYNOPSIS
-
-get_reference [options] referenceid [referenceid ...]
-
- Options:
- --pmid,-p referenceid is a pub med id. (Default)
- --bibtex,-b ouput in bibtex format (Default)
- --debug, -d debugging level (Default 0)
- --help,-h display this help
- --man,-m display manual
-
-=head1 OPTIONS
-
-=over
-
-=item B<--pmid, -p>
-
-The referenceid listed is a Pub Med ID. (Default)
-
-=item B<--bibtex, -b>
-
-Output the listed referenceid in BibTeX format. (Default)
-
-=item B<--help, -h>
-
-Display brief useage information.
-
-=item B<--man, -m>
-
-Display this manual.
-
-=back
-
-=head1 EXAMPLES
-
- get_reference -p -b -d 1 123456;
-
- get_reference 123456;
-
-=cut
-
-
-
-use vars qw($DEBUG);
-
-my %options = (pmid => 1,
- bibtex => 1,
- debug => 0,
- help => 0,
- man => 0,
- suggest_name => 0,
- journal_titles => 0,
- );
-
-GetOptions(\%options,'pmid|p','bibtex|b','suggest_name|suggest-name','debug|d','help|h','man|m',
- 'journal_titles|journal-titles|journal_title|journal-titles',
- );
-
-pod2usage() if $options{help};
-pod2usage({verbose=>2}) if $options{man};
-
-$DEBUG = $options{debug};
-
-if ($options{pmid} and $options{bibtex}) {
- use Reference::Type::Article;
- use Reference::Retrieve::PubMed;
- use Reference::Output::Bibtex;
- use Reference::Output::Filename;
- use Encode qw(encode_utf8);
- $Reference::Retrieve::PubMed::DEBUG = $options{debug};
- foreach my $pmid (@ARGV) {
- next unless ($pmid) = $pmid =~ /(\d+)/;
- print STDERR "dealing with $pmid\n" if $DEBUG;
- my $reference = scalar Reference::Retrieve::PubMed::get_reference_by_pmid(pmid => $pmid);
- print STDERR "Unable to retrieve reference for $pmid\n" and next if not defined $reference;
- if ($options{suggest_name}) {
- # try to suggest a name for the reference
- print '%Filename: '.lc(encode_utf8(Reference::Output::Bibtex::convert_to_utf8(filename($reference))))."\n";
- }
- if ($options{journal_titles}) {
- print '%Medline: @string {'.$reference->journal(output=>'bibtex').'="'.
- $reference->journal(output=>'medline').qq("}\n);
- print '%isoabbr: @string {'.$reference->journal(output=>'bibtex').'="'.
- $reference->journal(output=>'iso').qq("}\n);
- print '%full: @string {'.$reference->journal(output=>'bibtex').'="'.
- $reference->journal().qq("}\n);
- }
- print scalar bibtex($reference);
- }
-}