Hi Perl Gurus!

I am collecting temperature data from the CPUs in my system.  I want
to write this data into a comma-seperated text file, like so:

CPU1,65,63,62,64
CPU2,65,64,64,62
CPU3,64,65,66,64

Each line represents one CPU's temperature readings.  Each column
represents the time the reading was taken.  So, if I was taking the
readings once an hour, the above sample would be, for example, 12
Noon, 1pm, 2pm and 3pm.

I have successfully coded some Perl that pulls that data from the
system, but now I need to be able to a) determine if the file is empty
and, if so, start the file by adding the CPUx output. b) if the file
is not empty, add the next set of readings to the end of each line.

for a), I know I can do:

  if( -e <FILE>)

that's no problem.  My problem is b).  How can I read in all the lines
into their on arrays and add some data to the end?

my @wholefile = <FILE>;

Puts all the lines, one line per array element (with "\n" at the end).
 So, I can easily iterate through and chomp the "\n" out, then I can
add the latest temperature reading onto the end.

Ok, maybe I answered my own question.

So, let me take it a step further.  What if I wanted to read a
particular time's data out of the file; or add one into the middle? 
Can I get an array of arrays, Where one Array holds other arrays, each
other array holding the data (split into elements) of one line?

--Thanks

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to