On Dec 12, 2007 4:46 AM, Dr.Ruud <[EMAIL PROTECTED]> wrote:
> "Chas. Owens" schreef:
>
> > (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.
snip

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.

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


Reply via email to