> Ben Siders wrote: > > I'm not 100% confident that'll work as written. I *think* > that if the > > open is successful then the die will never execute and that > 'if' will > > never get checked. If the 'open' is successful on writing to a > > non-existant file, I'm not sure if this solution will correct it. > > > > Dan Muey wrote: > > > > > Open (...$file ...) || die "Oops I died : $@" if (-e $file); > > The Perl syntax is ok (except that it's open(), not Open()).
I know, Outlook automatically capitolizes the first letter sometimes and I'm stuck using it as I am at work. Sorry for any confusion there! > The -e test will occur first. If it succeeds, the open() will > be tried and if it fails, the die() will execute. So I'm not crazy after all!!! Woo Hoo!! > > But this kind of construct has a race condition: The file may > go into existence between the -e test and the open() call. Good point. > > The correct way to do this is to use sysopen with O_WRITE and > omit O_CREAT. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]