List the content of current folder : opendir « File « Perl






List the content of current folder

    

#!/usr/bin/perl -w

use strict;

print "contents of the new directory:\n";
opendir DH, '.' or die "opendir failed: $!";
my $filename;
while ($filename = readdir(DH)) {
    print "    $filename\n";
}
close DH;

   
    
    
    
  








Related examples in the same category

1.To open a directory, use the opendir command:
2.Get folder size, attributes and name
3.Use the functions opendir, readdir, and closedir