List the files and subdirectories in a directory. : readdir « File « Perl






List the files and subdirectories in a directory.

    
#!/usr/local/bin/perl 

opendir(HOMEDIR, "/u/jqpublic") || die ("Unable to open directory"); 
while ($filename = readdir(HOMEDIR)) { 
    print ("$filename\n"); 
} 
closedir(HOMEDIR); 

   
    
    
    
  








Related examples in the same category

1.Using readdir to get the content in a folder
2.Read a directory entry
3.The directory listing
4.To read a directory entry (usually a file name), use the readdir function