One technique that can help manage the time a file is open is to use lexical file handles:
... { open my $fileIn, '<', $filename or die "Failed to open $filename: +$!\n"; ... }
The end of the enclosing block (the '}') is the place where the lexical file handle ('$fileIn') goes out of scope and is closed if it hasn't been closed already.
In reply to Re: Why do we need to close filehandles?
by GrandFather
in thread Why do we need to close filehandles?
by tej
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |