On Sunday, August 11, 2002, at 04:21 AM, Ward W. Vuillemot wrote:
>
> On 2002.08.10, at 08:54, David Wheeler wrote:
>
>> On Saturday, August 10, 2002, at 12:43  AM, Shannon Murdoch wrote:
>>
>>> while(<FILE>){
>>>   push (@array,$_);
>>> }
>>
>> This doesn't answer your question, but just as a space saver 
>> (perhaps even optimization, I'm not sure), you might want to 
>> try this syntax:
>>
>> my @array = <FILE>;
>
> Q:  What happens if <FILE> is a LARGE file?  @array = <FILE> 
> may then cause problems...the first way ensures that the file 
> is read in pieces....

If the file is too big to fit comfortably in memory, then both 
of these will cause the same problem - lots of swapping, or an 
"Out of memory" error.

Why do you think the simpler version might cause problems?  In 
both cases you're putting the entire file into memory.  
Internally it's still being read one line at a time, too.  In 
practice, they both work fine.

  -Ken

Reply via email to