use -e to check if file exists on win32

M

mynews

The c:/dir is exist.

print -e 'C:/dir/"';
the result is 1 ,why?

print -e 'C:/"';
the result is null

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)
 
J

Joost Diepenmaat

mynews said:
The c:/dir is exist.

print -e 'C:/dir/"';
the result is 1 ,why?

Because -e checks if a "file" exists from a POSIX perspective, where
directories and symlinks are files - in other words, it checks if a path
exists. If you want to check if the path exists and is a file (not a
directory, or a symlink to a file), use -f.
print -e 'C:/"';
the result is null

Windows is strange. I would have expected some true value.
 
J

Joost Diepenmaat

Joost Diepenmaat said:
Because -e checks if a "file" exists from a POSIX perspective, where
directories and symlinks are files - in other words, it checks if a path
exists. If you want to check if the path exists and is a file (not a
directory, or a symlink to a file), use -f.
^^^^^^^^^^^^^^^^^ - I meant: "symlink to a directory"
 
M

mynews

But i don't have the (file/directory/symlink to a file) " .
Or the " have specially meaning on win32?
 
R

RedGrittyBrick

mynews said:
But i don't have the (file/directory/symlink to a file) " .
Or the " have specially meaning on win32?

Yes, Windows does do strange things with a trailing unbalanced quote mark.

C:\Users\RGB> dir C:\"
Volume in drive C is OS
Volume Serial Number is 49F8-F27B

Directory of C:\

18/09/2006 21:43 24 autoexec.bat
18/09/2006 21:43 10 config.sys
....

I don't have a file, directory or hotlink named " either (so far as I
can see).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top