El lun, 28-02-2005 a las 14:49 +0300, Vladimir D Belousov escribió:
1) if (-d $DIR_NAME) { .... directory exists };
2)
if((lstat($DIR_NAME))[1] & 0040000) {
.... directory exists and it is the real directory (not the symbolic link)
}else{
... No such directory or it is symbolic link
};
Carlos Mantero wrote:
Hi all,
I'm a begginer in Perl and other programming languages. I want to verify that a directory exists, but I don't know the way tho do it.
Regards.
Hi, I tested the code in my little script but the "if" bucle with the verify of the directory don't work fine, always print 1.
if ("-d /home/user") {
The above should not have quotes around it. This is telling Perl to check the truth of the string '-d /home/user' which will always be true. You need to unquote the test, if you are trying to interpolate a user variable you need to quote the path as a string not the whole test.
if (-d "/home/$user") {
print"1\n"; } else { print"2\n"; exit; }
I'm desperate because I don't know what is the problem...
Thanks.
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>