use HTTP::Cookies;
use HTML::Form;
use LWP;
use URI;
require 'dumpvar.pl';
my $LOGIN = 'lillyglobal'; # put your login name here
my $PASSWD = 'analysis';# password here
my $ua = LWP::UserAgent->new(); # Step 1
$ua->agent('Mozilla'); # habit
my $url = 'http://www.datamonitor.com/login.asp'; # Step 2
my $login_req = HTTP::Request->new(GET => $url); # Step 2
my $login_res = $ua->request($login_req); # Step 3
my $html = $login_res->content;
my $form = HTML::Form->parse($html,'http://www.datamonitor.com/login.asp'); # Step 4
dumpValue(\$form); # Step 5
$form->value('un',$LOGIN); # Step 6
$form->value('pw',$PASSWD); # Step 6
my $req = $form->click; # Step 7
my $res = $ua->request($req); # Step 8
my $cookie_jar = HTTP::Cookies->new(); # Step 9
$cookie_jar->extract_cookies($res); # Step 9
my $goto = $res->header('location'); # Step 10
my $new_req = HTTP::Request->new(GET => 'http://www.datamonitor.com/secure/listaccpurchases.asp') or
die "Can't get $goto: $!\n";; # Step 11
$cookie_jar->add_cookie_header($new_req); # Step 12
my $new_res = $ua->request($new_req); # Step 13
print $new_res->headers_as_string,"\n\n";
open (FH, ">D:\\Mustafa\\Perl\\Code\\dm.html") ||
die "Can't open file to write\n";
print FH $new_res->content; #if ($new_res->is_success);
print $new_res->content,"\n";