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 ]; } > my (@sv) = split(",",$strval); > my(@m1) = split(",",$m1vals); > my(@m2) = split(",",$m2vals); > > my(@data) = (@sv,@m1,@m2); > > Are @sv, @m1 and @m2 all arrays? Yes. > So, would @data be an array of arrays? No. > Or are the @sv, @m1 and @m2 arrays > flattened out, making @data just an array? Yes. > The thing is, with the fixed way of doing the graph, > and when I print out @data, I get > > ARRAY(....) ARRAY(....) ARRAY(...) Those are references to arrays. That is how Perl enables the use of multidimensional data structures. > But with the 'dynamic' way, I just get > ARRAY(...) > > where (....) are memory locations in Hex, I believe. Yes. > Can someone point out what I'm doing wrong? You could use the Data::Dumper module to display the contents of @data: use Data::Dumper; print Dumper( [EMAIL PROTECTED] ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]