1. Perl
  2. builtin functions
  3. here

closedir function - closes the directory handle

You can use the closedir function to close the directory handle opened by opendir function.

closedir directory handle

Example program

This is an example program that uses the closeddir function .

# Directory name
my $dir = 'study';

# Open directory
opendir my $dh, $dir
  or die "Can't open directory $dir:$!"

# Close directory handle
closedir $dh;

Related Informatrion