Your backslashes in double quotes represents an escaped character. You could use single quotes:
'\\pcname-vm\c$\program files\adobe'
Or you could use double quotes with multiple escaping to compensate for the escaping:
Or, finally, you could use forward slashes:"\\\\pcname-vm\\c$\\program files\\adobe"
"//pcname-vm/c$/program files/adobe"
Also, you should remove any non-directories from your list.
use strict; use warnings; my $directory = "//pcname-vm/c$/program files/adobe"; open(NDIR, $directory) or die "Error: $!"; my @folders; while (my $filename = readdir(NDIR)) { # skip the . and .. directories next if ($filename =~ /^.+$/); my $folder = "$directory/$filename"; # skip if not a directory next if (! -d $folder); push(@folders, $filename); } close(NDIR); foreach (@folders) { print "$_\n"; }
In reply to Re: Quickest way to get a list of all folders in a directory
by tokpela
in thread Quickest way to get a list of all folders in a directory
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |