Hi,

I'm trying to create a dynamic set of arrays to pipe into GD::Graph.

This works fine:

@data=([@array1],[@array2],[@array3]); my $gd = $graph->plot(\@data) or die $graph->error;
My question: How do i make @data have X set of arrays.

e.g.

for ($x=1; $x<10; $x++) { @anotherarray=(1,2,3,4,5); push @data, [ @anotherarray ]; } my $gd = $graph->plot(\@data) or die $graph->error;
which should give 9 lines?

I just get no points defined, or more specifically: No data sets or points :-(

UPDATE:
I'll give full details of what i'm trying to do. It's basically a traffic graph from multiple flat text files representing data streams.
They are in the format
TIME(HH:MM:SS):KBITS I open each file:

foreach $file (@files) { undef @timestamp; undef @kbits; open FILE, "$file"; @points=<FILE>; foreach $point (@points) { @split=split /:/, $point; push @timestamp, $split[0]; push @kbits, $split[1]; #### NOW IDEALLY, I WANT TO ADD @kbits TO THE DATA SET ### something like this: push (@data, [ @kbits ] ); #forget the timestamp for now- that just c +omplicates matters! } ## BUT I CAN'T, SO I JUST CURRENTLY TAKE THE LAST SET OF DATA # this gives no error @data=([@timestamp],[@kbits]); I'm using fatalstobrowser so the exact error is: No data sets or points at /home/web/http/volgraph.pl line 250. }

In reply to GD @data array question by andy_7t

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.