# # # This script demonstrates querying account history # using PerfectMoney API interface. # # # This sample Perl-script is provided AS IS and you should # use it at your own risk. # You MUST modify it before using with your particular # PerfectMoney account. # # # trying to open URL use LWP::UserAgent; use Data::Dumper; $ua = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1,timeout => 30); $request = HTTP::Request->new(GET =>"https://perfectmoney.com/acct/historycsv.asp?startmonth=1&startday=1&startyear=2007&endmonth=6&endday=30&endyear=2009&AccountID=111111&PassPhrase=aaa111"); $response = $ua->request($request); if (!$response->is_success) { print "Error openning URL"; exit; } # putting data into array (line per item) @data = (); @lines = split('\n', $response->content); if ($lines[0] != "Time,Type,Batch,Currency,Amount,Fee,Payer Account,Payee Account,Memo") { print $lines[0]; # print error message } else { # do parsing for ($i = 1; $i < scalar(@lines); $i++) { @item = split(',', $lines[$i], 9); if (scalar(@item) != 9) { next; } # line is invalid - pass to next one $item_named{'Time'} = $item[0]; $item_named{'Type'} = $item[1]; $item_named{'Batch'} = $item[2]; $item_named{'Currency'} = $item[3]; $item_named{'Amount'} = $item[4]; $item_named{'Fee'} = $item[5]; $item_named{'Payer Account'} = $item[6]; $item_named{'Payee Account'} = $item[7]; $item_named{'Memo'} = $item[8]; $data[@data]= $item_named; # push hash to array } } print "
\n";
  foreach $h(@data) {
    while (($k,$v) = each %h ) {
      print "$k => $v\n";
    }
  }
print "
";