Hiya monks! I need to know whats up with the following code. The output file is slightly messy with this
header that needs to be manually removed before it is recognized as an XML file. Also need to remove this[$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => ' ]
[', '_rc' => 200, '_headers' => bless( { 'connection' => 'close', 'client-response-num' => 1, 'set-cookie' => [ 'JSESSIONID= +BE2F6D38D966061A16CF2F63D893143A; Path=/spectrum/; HttpOnly', 'SMSESSION=" +IjLJvilHyYsuRGRh/POaQ68H5im603oJpRtWTfYztzCuZ0AwpK5bUJejgvJtX45N3GA4d +Uq4nFXF9886gH9HbRARbtTCW3PRsdwnwX7Sz9PSsF7Ji3/RSHfwuoPTQMA74GWCXRXAFD +5fj8IQPYFcJYCydsTbf95vMaSVe+BTHz6kXfWSLtPqt6ubYFIPm0vE0kHHv1y4fSzpSre +Pa8y9+spQuVS1jwq7nm5rYrGyEtwXU/9GUPOagieq7pcv6BfZwBG5O2VLfXa6n0JYCD7a +htTYMKwdiOASHZPPQHyadeRD/1VM0ZvBtA4H7QLiaeHLNLeqaL5QkkIeMaruIIWku6cQy +5QsatB3BYJbHD6QUlKSazNyxkHWYNXt+fsGszJJCu29L86Bk1Ks2k+C8PWUjDIXURlp+H +wg7kk+O/CFgBpij8cp4QpHh7QT16WE4MO1zjxYjGJVFHVTwJlcsFFpCr2V0HJFVdDNxXe +hwo/PwN+X5AFhKBExxKylP4/KSn/lY9IXBrZBPKfmC5PtBhJB1k2eqNZtIBdrRyvyEMep +YxqRIofsSnH7UC1pOhw/MDzUch7YYm6aVf8RhVUst0+u+fCxI1cvt2SpBZgBqYk9FJ2xw +GG5DZ6LbL1TEuP0okjK/B7kV7+Ov8z3O0OZ+9D2VYYFb0mQgEMBU/wbJ0N4YxgMqv1GSy +ejoMHKj7FKCPUdedM6a5mSK6sryDHVl1lTAiYpQ+CCJzBoE9oyMgUhnBj8zT95jn13tQP +AllK0NarvlwGjuOYABKwVJhoMKif3uXGTAyVLyJ+BJlinI57OhvgbZ14ZmAOerKFozhr3 +oLNCAHvhf0XXrSuORePcRs2SGnK2JFXk6SKsewoXVSaG+dR5yN//gme99DDWBO5HdD6yx +W3v/KhNU+i42+GQ40tdiBwPDJ4Vq6EPWvVnKuBPeAEZn4RGlmoaar971AdMk/GKfWpAyo +e5SHRbN36dyFQQspRQc0A5ppxtHynDEr7/2jU="; Version=1; Domain=.samsv2.gi +tn.com.my; Path=/' ], 'cache-control' => 'private', 'date' => 'Thu, 03 Jan 2013 04 +:13:13 GMT', 'client-peer' => '10.251.1.122 +:8080', 'authorization' => 'Basic c3Bl +Y3RydW06c3BlY3RydW0=', '::std_case' => { 'base' => 'B +ase', 'content-bas +e' => 'Content-Base', 'client-resp +onse-num' => 'Client-Response-Num', 'set-cookie' + => 'Set-Cookie', 'client-peer +' => 'Client-Peer', 'client-date +' => 'Client-Date', 'set-cookie2 +' => 'Set-Cookie2', 'client-tran +sfer-encoding' => 'Client-Transfer-Encoding' }, 'client-date' => 'Thu, 03 Jan +2013 04:15:14 GMT', 'content-type' => 'application +/xml', 'client-transfer-encoding' => +[ + 'chunked' +], 'server' => 'Apache-Coyote/1.1 +', 'expires' => 'Thu, 01 Jan 1970 + 07:30:00 MYT' }, 'HTTP::Headers' ), '_msg' => 'OK', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://10.251.1.122:8080/spectrum/restful/devices?attr=0x1000a&attr= +0x10009')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => 'WWW-Mechanize/1.72', 'accept +-encoding' => 'gzip', 'author +ization' => 'Basic c3BlY3RydW06UEBzc3cwcmQ= ' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' ); ]
#!Perl #use strict; use HTTP::Request::Common; use XML::Simple; use XML::Dumper; use Data::Dumper; use WWW::Mechanize; use MIME::Base64; my $url = 'http://10.251.1.122:8080/spectrum/restful/devices?attr=0x10 +00a&attr=0x10009'; my $Domain = 'spectrum'; my $UserName = 'spectrum'; my $Password = "P\@ssw0rd"; my $outfile = "result.xml"; my $agent = WWW::Mechanize->new(); my @args = ( Authorization => "Basic " . MIME::Base64::encode( $UserName . ':' . $Password ) ); $agent->credentials( 'http://10.251.1.122:8080' , $Domain, $UserName, $Password ); my $results = $agent->get( $url, @args ); #print Dumper($results); open(OUTFILE, ">$outfile") || die "could not open output file"; print OUTFILE Dumper($results); close(OUTFILE); print "done\n";
Is there any code to add/remove/modify? Thanks guys n gals!
In reply to cleanup XML output file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |