title: Providing username and password on a pop up window when a webpage is opened in Perl
body: <p>I've a webpage which needs to be updated and its a authenticated webpage. When i try to access the webpage, a pop-up window opens to ask for a username and password. How do i provide username and password on the pop up window. I've the below code written but its giving "Unauthorized" error message. When i manually provide the link a pop-up opens and it i click cancel the same "Unauthorized" message comes up. How do i change the below code of mine to provide username and password on a pop-up window and then click OK button on the pop-up.</p>
  
  <pre><code>#!/usr/bin/perl
  use LWP::UserAgent;
  use WWW::Mechanize;
  use HTTP::Cookies;
  use Crypt::SSLeay;
  use strict;
  use warnings;
  
  my $username="sqar";
  my $password="Pal500";
  my $agent = WWW::Mechanize-&gt;new(autocheck =&gt; [1]);
  my $url = 'http://example.com/content/Jen%20Automation.doc';
  $agent-&gt;get($url);
  $agent-&gt;field("os_username", $username);
  $agent-&gt;field("os_password", $password);
  $agent-&gt;submit();
  print "AFter login\n";
  my @links = $agent-&gt;find_all_links();
  
  foreach $lin(@links){
  
      unless ($lin-&gt;[0] =~ /^http?:\/\//i) {
              $lin-&gt;[0] = "$url" . $lin-&gt;[0];
      }
      print "$lin-&gt;[0]" ;
      print "\n";
  }
  </code></pre>
  
  <p>The pop-up window displays the message:</p>
  
  <blockquote>
    <p>the server example.com at WebDAV Server requires username and password</p>
  </blockquote>
  
  <p>along with text fields for entering username and password.</p>