title: convert perl code to php? (2)
body: <p>This is the perl code ...</p>
  
  <pre><code>use strict;
  use warnings;
  use LWP::UserAgent;
  use HTTP::Date;
  
  my $taxon = $ARGV[0]; # Taxonomy identifier of organism.
  
  my $query = "http://www.uniprot.org/uniprot/?query=organism:$taxon&amp;format=fasta&amp;include=yes";
  my $file = $taxon . '.fasta';
  
  my $agent = LWP::UserAgent-&gt;new;
  my $response = $agent-&gt;mirror($query, $file);
  
  if ($response-&gt;is_success) {
      my $results = $response-&gt;header('X-Total-Results');
      my $release = $response-&gt;header('X-UniProt-Release');
      my $date = sprintf("%4d-%02d-%02d", HTTP::Date::parse_date($response-&gt;header('Last-Modified')));
      print "Downloaded $results entries of UniProt release $release ($date) to file $file\n";
  }
  elsif ($response-&gt;code == HTTP::Status::RC_NOT_MODIFIED) {
      print "Data for taxon $taxon is up-to-date.\n";
  }
  else {
      die 'Failed, got ' . $response-&gt;status_line .
          ' for ' . $response-&gt;request-&gt;uri . "\n";
  }
  </code></pre>
  
  <p>I have tried converting this to php...
  there are still lines of codes that are in errors: in the else if statement..
  If you spotted other errors please comment it here...</p>
  
  <p>Here is what I  have tried so far</p>
  
  <pre><code>$taxon = $ARGV[0]; # Taxonomy identifier of organism.
  
  $query = "http://www.uniprot.org/uniprot/?query=organism:$taxon&amp;format=fasta&amp;include=yes";
  $file = $taxon . '.fasta';
  
  $response = $agent-&gt;mirror($query, $file);
  
  if ($response-&gt;is_success) {
    $results = $response-&gt;header('X-Total-Results');
    $release = $response-&gt;header('X-UniProt-Release');
    $date = sprintf("%4d-%02d-%02d", date_parse($response-&gt;header('Last-Modified')));
    print "Downloaded $results entries of UniProt release $release ($date) to file $file\n";
  }
  elsif ($response-&gt;code == HTTP::Status::RC_NOT_MODIFIED) {
    print "Data for taxon $taxon is up-to-date.\n";
  }
  else {
    die ('Failed, got ' . $response-&gt;status_line .
      ' for ' . $response-&gt;request-&gt;uri . "\n");
  }
  </code></pre>