This code will read the entire file into the array.  This works fine for
SMALL files.  When you get into large files, the program will take up more
RAM than the file takes on disk.

You also probably won't eliminate your loops.  They may no longer be while
loops, but you will likely still need to loop through the data in the array
just like you were in the file.

                                /\/\ark

-----Original Message-----
From: Josef E. Galea [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 2:15 PM
To: Ron Powell
Cc: [EMAIL PROTECTED]
Subject: Re: Help Please


RE: Help PleaseYep it reads each line in an array location i.e. in array
location 0 it reads the first line, in array location 1 the second line
etc...

The complete code is:

$file = "your text file name";
open (FILE, "$file");
@contents = <FILE>;
close (FILE);

This is all the code, feel free to use it. This means that $contents[0] =
line 1
$contents[1] = line 2
$contents[2] = line 3
  ----- Original Message -----
  From: Ron Powell
  To: 'Josef E. Galea'
  Sent: Tuesday, April 30, 2002 11:09 PM
  Subject: RE: Help Please


  Does the project you are working on require you to read more than one line
from the file in question?  I'm curious to see if your code, as posted, will
read more than one line...  If so, I can eliminate a _ton_ of while loops :)

  Thanks,
  Ron

  > -----Original Message-----
  > From: Josef E. Galea [mailto:[EMAIL PROTECTED]]
  > Sent: Tuesday, April 30, 2002 4:16 PM
  > To: [EMAIL PROTECTED]
  > Subject: Re: Help Please
  >
  >
  > Ok guys, thank you all for your suggestions. I solved the
  > problem. It consisted of a bug with the text editor that
  > saved the file as test.txt.txt. Rather lame actually. Thank you all
  >
  > Josef
  >



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

Reply via email to