Prev

Perl Notes

Next

Chapter 9.3 Closing a directory

Once you've finished looking at a directory's contents, you should close the directory.

To close a directory:
Type closedir(LABEL);, where LABEL is the directory handle you used when opening the directory in Chapter 9.1.


opendir(LOGDIR, ".") || @ErrorMessage;
@files = readdir (LOGDIR);
closedir(LOGDIR);
if (@files) {
  print "You can choose from the following logs:";
  foreach $filename (@files) {
    print $filename unless ($filename =~ /^\.+$/);
  }
}


Prev Home Next