Wednesday, January 23, 2013

Perl 에서 directory 내의 모든 file 리스팅하는 법

 #!/usr/bin/perl -w  
   
 use strict;  
 use warnings;  
   
 my $dir = "/Users/username/documents folder";  
   
 opendir(DIR, $dir) or die $!;  
   
 while (my $file = readdir(DIR)) {  
      next if ($file =~ m/^\./); # ignore filenames starting with a dot.  
      print "$file\n";  
 }  
   
 closedir(DIR);  
 exit 0;  
키워드 : folder, listing, iterate
레퍼런스 : How do I list the files in a directory?

No comments:

Post a Comment