The closedir function closes the directory that was opened by the opendir function. : closedir « File « Perl






The closedir function closes the directory that was opened by the opendir function.

    

#Format

#closedir (DIRHANDLE);
#closedir DIRHANDLE;


opendir(DIR, "..") || die "Can't open: $!\n";
@parentfiles=readdir(DIR);
closedir(DIR);
foreach $file ( @parentfiles ){ 
   print "$file\n";
}

   
    
    
    
  








Related examples in the same category

1.List the files and subdirectories in a directory in alphabetical order.
2.When you're done with a directory, you need to close it with the closedir command: