#all this works: my $xmlsimple = XML::Simple->new(); my $response = $xmlsiple->XMLin($xml_content->content); print "resultid:" . $response->{channel}->{result}->{resultid}; #this doesn't work: my $resultid = $response->{channel}->{result}->{resultid}; print "resultid: " . $resultid; #### use XML::Simple; use LWP::Simple; use Data::Dumper; use HTTP::Request::Common; use LWP::UserAgent; my $url = "http://localhost/xml/add_order.xml"; my $UserAgent = LWP::UserAgent->new(agent => 'perl post'); my $xml_content = $UserAgent->request(POST $url,["userid" => $userid, "password" => $password, "projectid" => $projectid, "ordertypeid" => $ordertypeid, "orderdateid" => $orderdateid, "accountid" => $accountid, "segcodeid" => $segcodeid, "marketid" => $marketid, "marketday" => $marketday, "marketmonth" => $marketmonth, "marketyear" => $marketyear, "putcall" => $putcall, "strikeprice" => $strikeprice, "bs" => $bs, "quantity" => $quantity, "orderprice" => $orderprice, "entered_by" => $entered_by ]); print $xml_content->error_as_HTML unless $xml_content->is_success; #if we want to see the XML #printf $xml_content->content; # also see ->code, ->is_info, ->is_success, ->is_error, ->header, ->message, etc my $xmlsimple = XML::Simple->new( ); my $response = $xmlsimple->XMLin($xml_content->content); #if we wanted to see the object as a structure: #printf Dumper($response); if ($response->{channel}->{error}->{errorid} == "") { print "resultid: " . $response->{channel}->{result}->{resultid} . "\n"; print "resultdesc: " . $response->{channel}->{result}->{resultdesc} . "\n"; print "orderid: " . $response->{channel}->{result}->{orderid} . "\n"; my $resultid = $response->{channel}->{result}->{resultid}; #ERROR my $resultdesc = ${\$response->{channel}->{result}->{resultdesc}}; #ERROR my $orderid = $response->{channel}->{result}->{orderid}; #ERROR printf "ERROR resultid:" . $resultid . "\n"; printf "ERROR: resultdesc:" . \$resultdesc . "\n"; printf "ERROR: orderid:" . $orderid . "\n\n"; # foreach my $tmp (@{$response->{channel}->{result}}) { # print "resultid: " . $tmp->{resultid} . "\n"; # print "resultdesc: " . $tmp->{resultdesc} . "\n"; # print "orderid: " . $tmp->{orderid} . "\n"; # print "\n"; # } } else { print "errorid: " . $response->{channel}->{error}->{errorid} . "\n"; print "error desc: " . $response->{channel}->{error}->{errordesc} . "\n"; print "\n"; }; my @ret_arry = ("test", $resultid, $resultdesc, $orderid); printf "ret_arry0:" . $ret_arry[0] . "\n"; printf "ret_arry1:" . $ret_arry[1] . "\n"; printf "ERROR ret_arry2:" . $ret_arry[2] . "\n"; printf "ERROR ret_arry3:" . $ret_arry[3] . "\n\n"; #%ret_hash = (resultid => "a", # resultdesc => "b"); return @ret_arry; #### Adding order resultid: 0 resultdesc: Success - Order 109 has been added to ProjectID 4217. orderid: 109 ERROR resultid:0 ERROR: resultdesc:SCALAR(0x181187c) ERROR: orderid:109 ret_arry0:test ret_arry1: ERROR ret_arry2: ERROR ret_arry3: array: test arry0: test arry1: ERROR arry2: ERROR arry3: done