"Ant" <> wrote in news:1147267243.388953.307580
@i39g2000cwa.googlegroups.com:
> For example, the following snippet of code should yield 3 invalid
> directory responses.
>
> my $folderExists = -d "C:Foo";
> my $folderExists2 = -d "C:\\Foo";
> my $folderExists3 = -d "";
>
> None of the above folders/directories exist (using XP Pro) yet the
> result of $folderExists is 1.
Please post a short but complete script along with its output when you
post code. It is hard to tell what you are printing and how.
> The others yield undefined values which is/should be correct.
All of the various methods below give the expected results for me
(c:/opt exists and is a directory on my system).
#!/usr/bin/perl
use warnings;
use strict;
use Data:

umper;
my @dirs = ('C:Foo', 'C:/Foo', q{}, 'C:/opt');
{
my @flags = map { -d $_ ? 1 : 0 } @dirs;
print "$_\n" for @flags;
}
{
my @flags = map { -d $_ } @dirs;
print Dumper \@flags;
}
{
my @flags;
for my $i ( 0 .. $#dirs ) {
$flags[$i] = -d $dirs[$i];
}
print Dumper \@flags;
}
{
my $e1 = -d 'C:Foo';
my $e2 = -d 'C:/Foo';
my $e3 = -d q{};
print "$_\n" for $e1, $e2, $e3;
}
__END__
> Has anyone encountered this
No.
> or is C:Foo being interpreted as something
> else (my only assumption - like C: on its own).
C:Foo is *NOT* the same as C:\Foo. I think C:Foo refers to something
called Foo in the current directory on drive C which, in your case,
seems to have a subdirectory called Foo.
Or, there is something else going on, but it is hard to know because you
did not show the exact code you ran.
For example:
D:\Home\asu1\UseNet\clpmisc> cat ddd.pl
#!/usr/bin/perl
use warnings;
use strict;
my @dirs = ('C:Foo', 'C:/Foo', q{}, 'C:/opt');
{
my @flags = map { -d $_ ? 1 : 0 } @dirs;
print "$_\n" for @flags;
}
__END__
D:\Home\asu1\UseNet\clpmisc> ddd
1
0
0
1
D:\Home\asu1\UseNet\clpmisc> c:
C:\opt\psdk> dir | grep Foo
05/10/2006 09:45 AM <DIR> Foo
--
A. Sinan Unur <>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html