On 6/30/2004 4:38 PM, perl.org wrote:

If the file is relatively small, why not read it into an array, then just
manipulate the array index?  Something like:

my @{lines} = <IN>;

Small pet peeve: slurping entire files is a bad habbit in general. Once your program allocates memory, it can never be freed even if you undefine every variable in your script. Use only what you need: no more, no less. Some tasks do require being able to see the entire file at once; these are rare and are probably the only exception. Even small files are better handled one piece at a time.


Buffering input is generally the most efficient way of handling the peek ahead problem. It saves you from having to seek back and forth in the file which is relatively expensive.

Randy.


-- 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