[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Writable file test broken?



At 10.28 -0400 1998.09.29, Bart Lateur wrote:
>On Tue, 29 Sep 1998 07:46:09 -0400, Chris Nandor wrote:
>
>>At 23.51 -0400 1998.09.28, Mat Marcus wrote:
>>>When I use the '-w' file test on a soft-locked file I get back 'true'. What
>>>is the recommended way to test mac file writability?
>>
>>  if (open(FILE, ">$file")) {
>>     # $file is writable :)
>>  }
>
>You're kidding, right?
>
>This will not only test if the file is writeable, but will destroy it in
>the process, too.
>
>The next variant is safer:
>
>  if (open(FILE, ">>$file")) { ... }
>
>and I hope it works, too.

I am sure it does.  But usually when I would check for writability, it
means I am going to open with > anyway.  So it depends on what your needs
are.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch