Here's a little snippet that I came up with that will put the correct data in @data. It was an interesting little problem and I wanted to play with it. You may have to tweak it to get it to do exactly what you want, but it should give you a headstart. There are a few things in there which may be confusing, so feel free to ask questions.

use strict; # returns the data as an array ref my $data = get_graph_data('header_data.dat', 'daily_data*.dat'); sub get_graph_data { my ($header,$file_name_format) = @_; my @dailies = glob($file_name_format); my @data; @dailies = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, get_number_in_string($_) ] } @dailies; foreach my $file ( $header, @dailies ) { local *IN; open IN, "< $file" or die "Cannot open ($file) for reading: $ +!"; push @data => [<IN>]; close IN or die "Cannot close ($file): $!"; } return \@data; } sub get_number_in_string { # returns the first instance of one or more digits in string my $string = shift || ''; my ($number) = $string =~ /^([[:digit:]]+)$/; return $number; }

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)


In reply to Re: Graphing basics.. by Ovid
in thread Graphing basics.. by Anonymous Monk

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.