Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4 Closing Filehandles

Filehandles are closed using the .close. operator and with the name of the filehandle to be closed as the argument:

close MYDATA;
The general recommendation is to close a filehandle once you have finished using it in your program. There are a couple of reasons for this. Firstly it is good behavior to close file when you have finished working with it to avoid unnecessary use of system resources. Secondly, it causes the operating system to flush the output buffers to the file thereby ensuring that all the data gets written to the file or stream. An unexpected system crash while you have a filehandle open could result in a truncated data file.

  Published under the terms of the GNU General Public License Design by Interspire