Cool File & Directory Modules IO::File 12 of 69 : prev | index | next

IO::File

Normal use of filehandles:

open FH, ">$file" or die "Cannot write file [$file]: $!\n";
while(<FH>) { ... }
close FH;

All well and good, but what if you forget to close FH ?

  • exit the script, file is closed in garbage collection
  • open the same FH handler and the previous file is closed before opening.
  • But that can mean your file may be open for a very long time.
  • Could block access to the file for other processes

© 2003 Barbie - barbie@missbarbell.co.uk contents http://birmingham.pm.org/