title: Perl — HTTP::Request::Common — POST file AND array
body: <p>I'm trying to POST file into a webapp endpoint. The problem is that in the same request I need to include array as a value of one of the parameters.</p>
  
  <pre><code>my $ua = LWP::UserAgent-&gt;new();
  my $response = $ua-&gt;post(
      $baseurl_local . 'create',
      Content_Type =&gt; 'form-data',
      Content      =&gt; [
      file =&gt;  [$file],
      targetLang =&gt; 'french',
  ]);
  </code></pre>
  
  <p>works just fine.</p>
  
  <p>However when I try to</p>
  
  <pre><code>my $ua = LWP::UserAgent-&gt;new();
  my $response = $ua-&gt;post(
      $baseurl_local . 'create',
      Content_Type =&gt; 'form-data',
      Content      =&gt; [
      file =&gt;  [$file],
      targetLang =&gt; ['french','spanish],
  ]);
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>Can't open file french: No such file or directory at C:/Strawberry/perl/site/lib/HTTP/Request/Common.pm line 154.
    HTTP::Request::Common::form_data(ARRAY(0x6800698), undef, HTTP::Request=HASH(0x6803a70)) called at C:/Strawberry/perl/site/lib/HTTP/Request/Common.pm line 67</p>
  </blockquote>
  
  <p>It would seem Perl thinks array ref with languages is a file.</p>
  
  <p>what am I doing wrong?</p>
  
  <hr/>
  
  <p>To expand on the resolution based on Matt's answer: as I forgot to mention originally, the list of languages comes from user input, so I ended up doing something like:</p>
  
  <pre><code>my @languages = (targetLang =&gt; 'french', targetLang =&gt; 'spanish');
  my $ua = LWP::UserAgent-&gt;new();
  my $response = $ua-&gt;post(
      $baseurl_local . 'create',
      Content_Type =&gt; 'form-data',
      Content      =&gt; [
          file =&gt;  [$file],
          @languages,
  ]);
  </code></pre>