John W. Krahn wrote:
Cc wrote:

Hi,


Hello,


I'm a beginner at PERL.  I've used it on and off, but only
just recently got myself back into the picture.  I figured
that if you forget something in PERL, it'd be easy to take
it up again.  So far, I'm not too sure of the ease
of taking up PERL again.  Before, I made a few perl scripts.
Now, when I look back, I find the whole thing overwhelming.
Even with comments...Anyway, I digress..

I have a text file with each line of the following format:

string1 string2 val1 val2 val3

I'm trying to read it into an array of arrays so I can
stick it in the creategraph() function to create a  line
graph.

So far, if I specifically create an array constant:

ie.

my(@data) = ( ["test 1",0.34,0.56,0.33],
                ["test 2",0.44,0.55,0.22],
                 ["final test",0.67,0.22,0.54])

my($grp) = new GD::Graph::linespoints();

and then put that in the $grp->plot([EMAIL PROTECTED]) function, I get
a graph.

But, if I use the following code:

while (<MYFILE>){
      chomp($_);
      @info = split(" ",$_);
      my($strngval) = "\"$info[0] $info[1]\"";
      $strval = "$strval,$strngval";
      $m1vals = "$m1vals,$info[2]";
      $m2vals = "$m2vals,$info[3]";
}


From your description, you probably want something like this:

my @data;

while ( <MYFILE> ) {
    my ( $str1, $str2, @info ) = split;
    push @data, [ "$str1 $str2", @info ];
}


I just realized that I had actually seperated the data into homogenous arrays; that is, one array carries all the string values, one consists of one set of values, and the last array consisting of the maximum values. I'm beginning to understand where I goofed.

You could use the Data::Dumper module to display the contents of @data:

use Data::Dumper;

print Dumper( [EMAIL PROTECTED] );

Thanks for the help! Very much appreciated.


Edmund


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to