Question : Perl list files and folders in a directory
Answered by : vternal3
my $dir = "bla/bla/upload";
opendir DIR,$dir;
my @dir = readdir(DIR);
close DIR;
foreach(@dir){ if (-f $dir . "/" . $_ ){ print $_," : file\n"; }elsif(-d $dir . "/" . $_){ print $_," : folder\n"; }else{ print $_," : other\n"; }
}
Source : https://stackoverflow.com/questions/1045792/how-can-i-list-all-of-the-files-in-a-directory-with-perl | Last Update : Tue, 19 Oct 21
Question : Perl list files and folders in a directory
Answered by : vternal3
opendir my $dir, "/some/path" or die "Cannot open directory: $!";
my @files = readdir $dir;
closedir $dir;
Source : https://stackoverflow.com/questions/1045792/how-can-i-list-all-of-the-files-in-a-directory-with-perl | Last Update : Tue, 19 Oct 21
Question : Perl list files and folders in a directory
Answered by : vternal3
use File::Find;
my @content;
find( \&wanted, '/some/path');
do_something_with( @content );
exit;
sub wanted { push @content, $File::Find::name; return;
}
Source : https://stackoverflow.com/questions/1045792/how-can-i-list-all-of-the-files-in-a-directory-with-perl | Last Update : Tue, 19 Oct 21