>
>So, if I put a filehandle in the diamond, instead of empty diamond,  
>does that mean that the first would operate line by line and the  
>second would pull the whole file into memory?
>

When the diamond(<>) is appeared with while(),it means you read the file line 
by line.
ig,while(<FILEHANDLE>){ .. } and while(<>} { .. } are almost the same.

When the diamond(<>) is appeared on list context,it would read all file content 
in memory at one time.
ig,
my @file = <FILEHANDLE>;
or,
my @file = sort { ...} <FILEHANDLE>;
my @file = map { ...} <FILEHANDLE>;
my @file = grep { ... } <FILEHANDLE>;

This would slurp all the file content into memory.

but,when the diamond(<>) is appeared on scalar context,it just read one line 
each time.
ig,
my $file = scalar <FILEHANDLE>; 
or,
my $file = <FILEHANDLE>;
or just say,
<FILEHANDLE>;

This would read only one line in that file into memory.



--
mailto: [EMAIL PROTECTED]
http://home.arcor.de/jeffpang/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to