title: Connecting to Website with a Login/Cookie via a Proxy in Perl
body: <p>I wrote the following script in perl to connect to a website using a proxy.  Granted the proxy address might not be functional at this instant, but conditional on the proxy address yielding no problems, the code works fine.</p>
  
  <p>I am wondering how I may extend it to a website in which there is a cookie and in which I must provide a login.  That is, in the code, I would like to use: $mech->submit_form().  My problem is not how to code the $mech stuff for the cookie and login (I have successfully done that), but rather, how can I do this via a proxy address.  I ask, in part, because I am not even sure how to do this in a web browser.</p>
  
  <pre><code> #!/usr/bin/perl
  
   use strict;
   use warnings;
   use utf8;
   use WWW::Mechanize;
   use WWW::Mechanize::Link;
   use LWP::UserAgent;
   use Data::Dumper;
  
   BEGIN { $| = 1 }
   $ENV{'HTTP_PROXY'} = 'http://66.35.68.145:7808';
   $ENV{'HTTPS_PROXY'} = 'http://66.35.68.145:7808';
  
  my $mech = WWW::Mechanize-&gt;new();
  my $response = $mech-&gt;get("http://whatismyipaddress.com/");
  print Dumper($response-&gt;decoded_content);
  </code></pre>