I have a script that reads the contents of a directory. But the script can't open the directory because permission is denied. I am working on Windows, and I've tried to run the script as administrator, but that didn't help.
Here's the code:
sub dir_put {
my $dir_name = shift;
open DIR, $dir_name or die "Error reading directory: $!";
my @array;
my @return;
while ($_ = readdir(DIR)){
next if $_ eq "." or $_ eq "..";
if (-d $_) {
@return = dir_put($_);
unshift(@array, @return);
next;
}
unshift (@array, "$dir_name\\$_");
}
@array;
}
How should I fix it?