You'll probably get a few other examples but this is one way to do it:

p.s. This does assume you're splitting on spaces in your data file. If not, change the value in split to whatever is seperating your data.

#!/usr/bin/perl -w use strict; my @x; # your x values my @y; # your y values open FH, 'your file'; # whatever your data file is while (my $line = <FH>){ my @z = split ' ', $line; # split on space to get # your values in an array push(@x ,unshift @z); # take first element of z and # add it to x push(@y,$_) foreach(@z); # add the rest to y } close FH;

That may not be the cleanest way but to do what you want to do, the push and pop do work. After you have your values seperated, it should be trivial for you to work out the max values for each.

Good luck!

Some people fall from grace. I prefer a running start...

Update:

Aristotle was kind enough to point out I had misread the question slightly. Below is an updated version that's about as easy as I can do.

#!/usr/bin/perl -w use strict; my @x; # your x values my @y1; # your y values my @y2; my @y3; my @y4; die unless open FH, 'file.txt'; # whatever your data file # is my $count=0; while (my $line = <FH>){ ($x[$count], $y1[$count], $y2[$count], $y3[$count], $y4[$count]) = split ' ', $line; # split on space to get # your values in an array $count++; } close FH; print "X:@x\n1:@y1\n2:@y2\n3:@y3\n4:@y4\n";

Please ignore the top code unless you need to get a list of numbers in to two arrays with the first array holding the first number and the second the rest of the numbers for your file. : )


In reply to Re: n00b reading info from file by Popcorn Dave
in thread n00b reading info from file 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.