I have the iostat -x data which I have parsed and converted into XML using Test::Parser::Iostat. I need the parsed output to create a graph using GD else GD::Graph. I have created a hash with the keys and all the values associated with. But to use a GD::Graph I need to convert this hash to array of arrays to generate a graph. How do I do this else is it possible to utilize this hash to generate a Graph?

The code is #!/usr/bin/perl use strict; use warnings; use File::Slurp; use Data::Dumper; my %graph_point_hash; my @report_graph_point = `sed -e 's/data//g' -e 's/[\<\/\>]//g' -e 's/ +^ *//' -e 's/* \$//' -e '/^\$/d' -e '1d;\$d' $ARGV[0]`; my @split_graph_points; foreach (@report_graph_point) { @split_graph_points = split (' ', $_); foreach my $graph_point (@split_graph_points) { $graph_point =~ s/"//g; my ($key, $val) = split ("=", $graph_point); push (@{$graph_point_hash{$key}}, "$val"); } #foreach loop ends here } #foreach loop ends here print Dumper \%graph_point_hash; XML file is <iostat> <data avgqu="0" avgrq="0" await="0" device="sdb" elapsed_time="0" r= +"0" rmb="0" rrqm="0" svctm="0" util="0" w="0" wmb="0" wrqm="0" /> <data avgqu="0" avgrq="0" await="0" device="sda" elapsed_time="0" r= +"0" rmb="0" rrqm="0" svctm="0" util="0" w="0" wmb="0" wrqm="0" /> <data avgqu="0.00" avgrq="0.00" await="0.00" device="sdb" elapsed_ti +me="1" r="0.00" rmb="0.00" rrqm="0.00" svctm="0.00" util="0.00" w="0. +00" wmb="0.00" wrqm="0.00" /> <data avgqu="0.00" avgrq="58.91" await="0.09" device="sda" elapsed_t +ime="1" r="0.00" rmb="0.00" rrqm="0.00" svctm="0.09" util="0.05" w="5 +.50" wmb="324.00" wrqm="35.00" /> <data avgqu="0.00" avgrq="0.00" await="0.00" device="sdb" elapsed_ti +me="2" r="0.00" rmb="0.00" rrqm="0.00" svctm="0.00" util="0.00" w="0. +00" wmb="0.00" wrqm="0.00" /> THE OUTPUT IS $VAR1 = { 'w' => [ '0', '0', '0.00', '5.50', '0.00', '2.50', '0.00', '489.50', '0.00', '0.00', '0.00', '0.00', '0.00', '242.00', '0.00', '0.00', '0.00', '5.50', '0.00', '4.00',

In reply to I need to create a graph from a hash using GD else GD::Graph by rahulruns

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.