Hi Perl monks, sorry to ask a so simple question, but ihave been dodging with it for some hours.I have an XML file of the form,
<?xml version="1.0" encoding="UTF-8"?> <testResults version="1.2"> <httpSample t="704" lt="704" ts="1306146504248" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-1" dt="text" by="411"/> <httpSample t="525" lt="525" ts="1306146505234" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-2" dt="text" by="411"/> <httpSample t="526" lt="526" ts="1306146506234" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-3" dt="text" by="411"/> <httpSample t="586" lt="586" ts="1306146611316" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-1" dt="text" by="411"/> <httpSample t="523" lt="523" ts="1306146612307" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-2" dt="text" by="411"/> <httpSample t="507" lt="507" ts="1306146613306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-3" dt="text" by="411"/> <httpSample t="554" lt="554" ts="1306146614306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-4" dt="text" by="411"/> <httpSample t="535" lt="535" ts="1306146615306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-5" dt="text" by="411"/> </testResults>
now i need to find and display the maximum and minimum of lt value of each set( that is maximum and minimum values of lt from first three tags seperated by a newline and the next five tags inside a single program also similarly display the average of the two sets. I was able to fetch the lt values alone and display, but somewhere i have made some sort of mistake which devoids me from obtaining the desired output. kindly help.. for your information the code i used is as follows(to get lt value),
use strict; use warnings; use XML::Simple; use Data::Dumper; # create object my $xml_data = new XML::Simple (KeyAttr=>[]); # read XML file my $file_path='c:\catalog1'; my $data = $xml_data->XMLin($file_path); # dereference hash reference # access <httpSample> array foreach my $e (@{$data->{httpSample}}) { my @values = $e->{lt}; print "Lt_Value: ", @values, "\n"; print "\n"; }
In reply to find min, max and average by techtween
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |