title: Error reason from Perl Net::FTP
body: <p>I'm using Net::FTP to transfer files up to a mainframe and I'm testing failure conditions.</p>
  
  <p>My code is basically along the following lines:</p>
  
  <pre><code>    my $ftp = Net::FTP-&gt;new ("mainframe.com", Timeout =&gt; 20);
      if (! $ftp) {
              logMessage ("Could not connect to host: $!");
              return;
      }
  
      if (! $ftp-&gt;login ("paxdiablo", "demigodemporeroftheuniverse")) {
              logMessage ("Could not log in to host: $!");
              $ftp-&gt;quit ();
              return;
      }
  
      if (! $ftp-&gt;put ("myfile.txt", "'CANT.WRITE.TO.THIS'")) {
              logMessage ("Could not put file: $!");
              $ftp-&gt;quit ();
              return;
      }
  </code></pre>
  
  <p>I <em>know</em> I can't create the data set <code>CANT.WRITE.TO.THIS</code> since I don't have the required permissions but, when I try, the only message I see is:</p>
  
  <pre><code>Could not put file:
  </code></pre>
  
  <p>There is no indication in <code>$!</code> as to what the problem was. I've looked in the <a href="http://perldoc.perl.org/Net/FTP.html" rel="nofollow"><code>Net::FTP</code> doco</a> and all it says is:</p>
  
  <blockquote>
    <p><strong><code>put ( LOCAL_FILE [, REMOTE_FILE ] )</code></strong><br><br><code>Put a file on the remote server. LOCAL_FILE may be a name or a filehandle. If LOCAL_FILE is a filehandle then REMOTE_FILE must be specified. If REMOTE_FILE is not specified then the file will be stored in the current directory with the same leafname as LOCAL_FILE.</code><br><br><code>Returns REMOTE_FILE or the generated remote filename if REMOTE_FILE is not given.</code></p>
  </blockquote>
  
  <p>I also cannot find anything there about retrieving the specific error (like <code>$ftp-&gt;getLastError()</code> or something similar).</p>
  
  <p>How can I indicate to the user <em>why</em> the transfer failed?</p>
  
  <p>On an earlier iteration, I resorted to putting the file, then getting it again and checking contents locally. I'd really rather <em>not</em> have to inflict such kludgy code on people again.</p>