"Chas. Owens" schreef:
> Dr.Ruud:
>> Chas. Owens:

>>> (you should close file handles once you
>>> stop using them because they are a limited resource).
>>
>> I often start a new block at opening a file.
>
> If you are using the new scalar based file handles this is a good
> practice since they automagically close when the last reference to
> them goes out of scope.
>
> {
>     open my $fh, "<", $file
>         or die "could not open $file: $!";
>     #do things with file
> } #unless a reference was made to $fh it will close here
>
> But if you are still using (or working on code that still uses) the
> old bareword file handles, it will not close the file.  This is but
> one of the many advantages the new style file handles has over the old
> style.

Yes, thanks for the clarification. I detest code with bareword file
handles.

Your last comment line ("it will close here") I would put inside the
block, or I would say "is closed with the block".
(I am all for lexical comments.)

-- 
Affijn, Ruud

"Gewoon is een tijger."


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


Reply via email to