title: Implementing custom Curl authentication in Perl script
body: <p>I am building bot application trying to use perl script to implement the curl request, the issue I have is with Authorization.</p>
  
  <p>The simple curl command is something like.</p>
  
  <pre><code>curl \
    -H 'Authorization: Bearer VM2CKBMXI3AVX2GMYPLBMYFRW3RCHYXS' \
    'https://api.wit.ai/message?v=20160722&amp;q='
  </code></pre>
  
  <p>I preferred not to use system() calls from the Perl script as there will be  plenty of back and forth between the user and the bot.</p>
  
  <p>I found this library 
  <a href="http://search.cpan.org/~szbalint/WWW-Curl-4.17/lib/WWW/Curl.pm" rel="nofollow">http://search.cpan.org/~szbalint/WWW-Curl-4.17/lib/WWW/Curl.pm</a></p>
  
  <p>I was searching for setopt function in order to find out which params does it accept as my issue is where to put the Authorization param inside the command.
  I found this link 
  <a href="http://web.mit.edu/darwin/src/modules/curl/curl/perl/Curl_easy/easy.pm" rel="nofollow">http://web.mit.edu/darwin/src/modules/curl/curl/perl/Curl_easy/easy.pm</a></p>
  
  <p>My Script code for now it is like the following:</p>
  
  <pre><code>use strict;
  use warnings;
  use WWW::Curl::Easy;
  
  my $curl = WWW::Curl::Easy-&gt;new;
  my $Authorization="Authorization: Bearer VM2CKBMXI3AVX2GMYPLBMYFRW3RCHYXS";
  
  $curl-&gt;setopt(CURLOPT_HEADER,1);
  $curl-&gt;setopt(CURLOPT_URL, 'https://api.wit.ai/message?v=20160721&amp;q=hello');
  
  # A filehandle, reference to a scalar or reference to a typeglob can be used here.
  my $response_body;
  $curl-&gt;setopt(CURLOPT_WRITEDATA,\$response_body);
  
  # Starts the actual request
  my $retcode = $curl-&gt;perform;
  
  # Looking at the results...
  if ($retcode == 0) {
       print("Transfer went ok\n");
       my $response_code = $curl-&gt;getinfo(CURLINFO_HTTP_CODE);
       # judge result and next action based on $response_code
       print("Received response: $response_body\n");
  } else {
       # Error code, type of error, error message
       print("An error happened: $retcode ".$curl-&gt;strerror($retcode)." ".$curl-&gt;errbuf."\n");
  }
  </code></pre>
  
  <p>I just need to know which CURLOPT should I need to use in order to implement authorization. 
  If you have any idea that will be great.</p>
  
  <p>Thanks
  Eran Gross</p>