Hello, i would like to create a pie Chart using the GD Module from values that come in via a Database Query. The Graph is drawn from Data that are in the @data array, which should look like for example the following:
@data = (['Siemens','Nokia','Sony','Ericcson','Samsung'], [45000,12000,11000,18000,8000]);
I get my Values from a Database, so the Code for that part is
my $sth = $dbh->prepare("SELECT kunde,umsatz FROM db_kundenumsatz"); my @data; while (@data = $sth->fetchrow_array()){ #reading the data into an array of arrays just like the above }
So my Question is, while i am doing my fetchrow_array, how can i add the Values into my @data array of arrays, so that they are stored exactly like what i wrote above? Eg. so that Data Dumper would output it in this way
# i dont want to write this out by hand, but rather auto # create it via my Database Recordset that i fetched with # $sth->fetchrow_array() @data = (['Siemens','Nokia','Sony','Ericcson','Samsung'], [45000,12000,11000,18000,8000]); print Dumper(@data); $VAR1 = [ 'Siemens', 'Nokia', 'Sony', 'Ericcson', 'Samsung' ]; $VAR2 = [ 45000, 12000, 11000, 18000, 8000 ];
I read up on Array of Arrays, and tried a many ways suggested, but the Data just wont come out in the correct Format. If anyone could show me the way, that would be awesome. Thanks and best regards!

In reply to Getting Record Set via DBI into an Array of Arrays by overrider

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.