开发者

Check to see if c:\temp exists on local system - PERL / RegEx

开发者 https://www.devze.com 2023-03-25 12:21 出处:网络
What is wrong with my syntax: if (-d =~ /c:\\\\[Tt][Ee][Mm][Pp]/i) { print \"There is a directory c:\\\\TEMP already..\\n!\";

What is wrong with my syntax:

if (-d =~ /c:\\[Tt][Ee][Mm][Pp]/i) {
print "There is a directory c:\\TEMP already..\n!";
}
else {
print "didn't find";
开发者_运维知识库}


Instead of checking for C:\Temp or one of its many variants, you should either use a perl module written for handling temp files or use the Win32 API to obtain the temp folder.


I think you need opendir(my $dh,'C:\temp\\' or die;if(-d $dh){....

Check out perldoc -f '-x'


I figured it out: if (-e "c:\temp") {

0

精彩评论

暂无评论...
验证码 换一张
取 消