Spencer_Lists wrote: > Greetings perl-win32-users, > > This is not a strictly win32 question but relates to files in a win32 > system so ... > > The context is pretty obscure so I am including the very minimum code > snippet. @files is an array of all the files in the path folder. I > need to check whether the file $newname exists in the path folder. An > odd situation came up with a file named "blah blah blah (1940.mid" > The author of the file forgot the closing ) which is fine for a > windows file name but grep sees the "(" as missing the ")" in a regex. > I have tried quoting and preceding the ( or ) with \ to escape it but > none of this works. Any ideas? I could also just check the folder for > the presence of the file name but I have never found documentation on > how to do this. Since this would be more of a win32 question, maybe > that is what I should be asking. How do I check for the existence of a > file in a folder? > > my @files = <$path/*>; > my $file_exists = 1 if (grep/$newname/,@files);
Hi Spencer, That has an unusual syntax in Perl -- it's borrowed from Unix shell scripting. You test for the presence of a file with: if (-f "/path/to/file") { # do stuff here } There are other similar functions -- -r checks if the file is readable by the user running the script, and others. You can find more details in the perlfunc manual page ("perldoc perlfunc" on most systems). Cheers, kjw _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs