If you are using the code from my answer to your previous question, the only thing I can think of is that there might be some external dir.exe
on your path that does not understand the commandline options for cmd.exe
's built-in dir
. For example, with Cygwin's directories in my path, I get
dir: cannot access /ad/b/s: No such file or directory
You should also get in the habit of showing the exact output you are getting if you want people to be able to help you more effectively.
To make sure that does not happen, use:
use strict; use warnings;
use File::Basename;
my @dirs = grep { fileparse($_) =~ /^[Ll]ib/ }
split /\n/, `cmd.exe /c dir e:\\ /ad/b/s`;
print "$_\n" for @dirs;
Note the backticks `
. Note also the correction to the pattern you are using.