<p>Here is a starting point using <a href="https://metacpan.org/pod/XML::Twig" rel="nofollow noreferrer"><code>XML::Twig</code></a> to parse the downloaded XML file:</p>

<pre><code>use feature qw(say);
use strict;
use warnings;
use LWP::UserAgent;
use Text::BibTeX;
use Text::BibTeX::Entry;
use XML::Twig;
use DateTime::Format::Strptime;
{
    my $arxivid = "hep-ph/9609357";
    my $url = "http://export.arxiv.org/api/query?search_query=" . $arxivid . "&amp;start=0&amp;max_results=1";
    my $browser = LWP::UserAgent-&gt;new();
    my $response = $browser-&gt;get($url);
    my $xml = $response-&gt;content;
    my $twig = XML::Twig-&gt;new-&gt;parse( $xml );
    my $title = $twig-&gt;get_xpath ( '//entry/title',0 )-&gt;text;
    my @authors;
    for my $node ( $twig-&gt;findnodes( '//entry/author/name' )) {
        push @authors, $node-&gt;text;
    }
    my $doi = $twig-&gt;get_xpath ( '//entry/link[@title="doi"]',0 )-&gt;att('href');
    my $published = $twig-&gt;get_xpath ( '//entry/published',0 )-&gt;text;
    my ( $year, $month) = parse_published( $published) ;

    my $entry = Text::BibTeX::Entry-&gt;new();
    $entry-&gt;set_metatype(BTE_REGULAR);
    $entry-&gt;set_type('article');
    $entry-&gt;set_key('article1');
    $entry-&gt;set( 'title', $title );
    $entry-&gt;set( 'author', join ' and ', @authors );
    $entry-&gt;set( 'year', $year );
    $entry-&gt;set( 'month', $month );
    $entry-&gt;set( 'doi', $doi );
    $entry-&gt;print(\*STDOUT);
}

sub parse_published  {
    my ( $published) = @_;

    my $parser = DateTime::Format::Strptime-&gt;new(
        pattern =&gt; '%FT%T%Z',
        time_zone =&gt; 'UTC',
        on_error =&gt; 'croak',
    );

    my $dt = $parser-&gt;parse_datetime($published);

    return ( $dt-&gt;year, $dt-&gt;month_name);
}
</code></pre>

<p><strong>Output</strong>:</p>

<pre><code>@article{article1,
  title = {Mixing-induced CP Asymmetries in Inclusive $B$ Decays},
  author = {Martin Beneke and Gerhard Buchalla and Isard Dunietz},
  year = {1996},
  month = {September},
  doi = {http://dx.doi.org/10.1016/S0370-2693(96)01648-6},
}
</code></pre>
from arXiv ID to BibTeX entry
<p>How can I write a robust Perl script that will generate a BibTeX entry for an arXiv ID?</p>

<p>My guess is that I should use the <a href="https://arxiv.org/help/api/" rel="nofollow noreferrer">arXiv API</a> and parse its response with <a href="https://metacpan.org/pod/XML::Atom" rel="nofollow noreferrer">XML::Atom</a>. It should give me the needed pieces of information to build a BibTeX entry.</p>

<p>Here is how I would start:</p>

<pre><code>use LWP::UserAgent;
use Text::BibTeX::Entry;
use XML::Atom;

my $arxivid = "hep-ph/9609357";
my $url = "http://export.arxiv.org/api/query?search_query=" . $arxivid . "&amp;start=0&amp;max_results=1";
my $browser = LWP::UserAgent-&gt;new();
my $response = $browser-&gt;get($url);
my $entry = Text::BibTeX::Entry-&gt;new();
</code></pre>

<p>Answers not using the arXiv API or XML::Atom are welcome too.</p>