http://qs321.pair.com?node_id=1214670


in reply to HTTP PUT Request with separate values in csv

I just have to say it is very difficult to read your code. Maybe you can indent it properly. People would be much more inclined to try and help you. Also, are we supposed to know what is in 'example.xml'. Posting complete code listings is also not very useful. Try to simplify your question. Reading your code I am absolutely clueless in what you are actually try to do.

Nevertheless to help you on your way a little bit, try to focus on the actual problem. What is the problem? Is the problem in the part that examines the two csv files or is it in the server request. As a matter of fact that is where I would look first.

Create a small sample code for testing and once you have that part working, then start working on the rest of your code.

For example

I suggest you use strict and warnings, it will help you identify problems in your code much sooner.

use strict ; use warnings ;
my $xml = XML::Twig->new()->parsefile('example.xml') ; $xml-> ... ; $xml -> get_xpath('//ipaddress',0) -> set_text("<IP HERE>") ;

Write a test to check if the previous instruction worked. I don't know, are these of HTML::Element XML::Element? If so then print $xml->as_text() print $xml->as_XML could work. Once you know this worked, then move on:

my $uri="https://hostname:9060/ers/config/networkdevice/<ID HERE>"; my $req = HTTP::Request->new( ... $req->content($xml->sprint) ; # Strange, why is there another $xml->sp +rint here? $req->...

Now try to find more ways to introspect $req and see if it contains everything you want. Try to do a request and see if it works:

my $res = $ua->request( $req ) ; # Check the outcome of the response if ($res->is_success) { print $res->status_line, "\n"; } else { print $res->status_line, "\n"; }

edit: forgot to add the Twig parsefile instruction.