# # # This script demonstrates getting complete listing # of all e-Vouchers created by the Perfect Money user. # # # 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/evcsv.asp?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] != "Created,e-Voucher number,Activation code,Currency,Batch,Payer Account,Payee Account,Activated,Amount") { 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{'Created'} = $item[0]; $item_named{'Number'} = $item[1]; $item_named{'Code'} = $item[2]; $item_named{'Currency'} = $item[3]; $item_named{'Batch'} = $item[4]; $item_named{'Payer Account'} = $item[5]; $item_named{'Payee Account'} = $item[6]; $item_named{'Activated'} = $item[7]; $item_named{'Amount'} = $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 "
";