in reply to I need to create a graph from a hash using GD else GD::Graph
You should probably use a module to read your XML, but if you really want to do it manually and get an array of arrays, you might want to follow the lines of this session under the Perl debugger:
DB<54> $c = '<data avgqu="0" avgrq="0" await="0" device="sdb" elapse +d_time="0" r="0" rmb="0" rrqm="0" svctm="0" util="0" w="0" wmb="0" wr +qm="0" />'; DB<55> push @AoA, [$c =~ /"([.\d]+)"/g]; DB<56> $c = '<data avgqu="0.00" avgrq="58.91" await="0.09" device="s +da" elapsed_time="1" r="0.00" rmb="0.00" rrqm="0.00" svctm="0.09" uti +l="0.05" w="5.50" wmb="324.00" wrqm="35.00" />'; DB<57> push @AoA, [$c =~ /"([.\d]+)"/g]; DB<58> $c = '<data avgqu="0.00" avgrq="58.91" await="0.09" device="s +da" elapsed_time="1" r="0.00" rmb="0.00" rrqm="0.00" svctm="0.09" uti +l="0.05" w="8.50" wmb="332.00" wrqm="27.00" />'; DB<59> push @AoA, [$c =~ /"([.\d]+)"/g];
This gives you the following structure:
DB<60> x @AoA 0 ARRAY(0x80432550) 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 1 ARRAY(0x80438020) 0 0.00 1 58.91 2 0.09 3 1 4 0.00 5 0.00 6 0.00 7 0.09 8 0.05 9 5.50 10 324.00 11 35.00 2 ARRAY(0x804381d0) 0 0.00 1 58.91 2 0.09 3 1 4 0.00 5 0.00 6 0.00 7 0.09 8 0.05 9 8.50 10 332.00 11 27.00
But I am not sure that this is what you are looking for, you haven't given enough details.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I need to create a graph from a hash using GD else GD::Graph
by rahulruns (Scribe) on Sep 11, 2013 at 05:13 UTC | |
by poj (Abbot) on Sep 11, 2013 at 09:20 UTC | |
by Laurent_R (Canon) on Sep 11, 2013 at 06:36 UTC |