updating oE read_lines
File Reading and Writing
read_lines
include io.e namespace io public function read_lines(object file)
reads the contents of a file as a sequence of lines.
Parameters:
file : an object, either a file path or the handle to an open file. If this is an empty string, STDIN (the console) is used.
Returns:
-1 on error or a sequence, made of lines from the file, as gets could read them.
Comments:
If file was a sequence, the file will be closed on completion. Otherwise, it will remain open, but at end of file.
Example 1:
data = read_lines("my_file.txt") -- data contains the entire contents of ##my_file.txt##, 1 sequence per line: -- {"Line 1", "Line 2", "Line 3"}
Example 2:
fh = open("my_file.txt", "r") data = read_lines(fh) close(fh) -- data contains the entire contents of ##my_file.txt##, 1 sequence per line: -- {"Line 1", "Line 2", "Line 3"}
See Also:
Not Categorized, Please Help
|