in reply to Re: -d on windows
in thread -d on windows

Thanks for the reminder, it all came flooding back as soon as I read the first line.
Code changed too
my $dir = "e:\\core\\ops_utilities\\"; opendir DIR, $dir or die $!; my @files = grep {!-d $dir.$_} readdir(DIR);
And all works as expected. Thank you

Replies are listed 'Best First'.
Re^3: -d on windows
by ikegami (Patriarch) on Mar 27, 2008 at 13:57 UTC
    Here's a variation that doesn't require an unusual trailing backslash, gives a better error message, and avoids using global variables:
    use File::Spec::Functions qw( catfile ); my $dir = "e:\\core\\ops_utilities"; opendir(my $dh, $dir) or die("Unable to read utilities directory \"$dir\": $!\n"); my @files = grep { !-d catfile($dir, $_) } readdir($dh);

    The following might be more useful:

    my @files = grep { !-d } map { catdir($dir, $_) } readdir($dh);