Other than reading for a very long length (beyond the length that a file could ever be) what is the best way to read in a file. In my case the file could be anywhere upto around 1-5 meg big!
This works, but is obviously not great:-
sysopen(DF, "test.txt", O_RDONLY);
sysread DF, $rec, 26214400; #25meg
One further question, if that variable ($rec) has thousands of records which end in CR, what's the best way to split it up into an array (retaining the carriage returns)? ie: Anything better than simply doing this after the read?
$rec=''; # Release memory
Could it be cleverly combined into the read itself therefore meaning you don't have to use $rec and @array, and instead you could read it (ready split) straight into @array?