Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PERL

Perl list files and folders in a directory

my $dir = "bla/bla/upload";
opendir DIR,$dir;
my @dir = readdir(DIR);
close DIR;
foreach(@dir){
    if (-f $dir . "/" . $_ ){
        print $_,"   : file
";
    }elsif(-d $dir . "/" . $_){
        print $_,"   : folder
";
    }else{
        print $_,"   : other
";
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Perl #list #files #folders #directory
ADD COMMENT
Topic
Name
5+3 =