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

Re: [MacPerl] trouble with -w



At 20.23 97/5/27, Doyle B. Myers wrote:
>print "write to foo\n" if (-w "hd:foo");  # this one is locked
>print "write to bar"\n if (-w "hd:bar");  # this one is unlocked
>
>results:
>
>write to foo
>write to bar


My guess is that -w and -W test for writability by uid/gid, which doesn't
exist on MacOS.

Instead, try actually opening the file for appending.  This works for me:

#!perl
$dir = 'PowerPudge:Desktop Folder:test';
print "write to test1\n" if (open(D1,"+<$dir:test1") && close(D1));  #unlocked
print "write to test2\n" if (open(D2,"+<$dir:test2") && close(D2));  #locked

results:

write to test1


My first example for you opened the file for writing, which, of course,
erases the existing file.  Duh.  But opening it for appending does nothing
to the contents, and only returns successful if the file is writable.

Hope this helps,

--
Chris Nandor                 pudge@pobox.com                 http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6'])
#=============================================================================
    /* now make a new head in the exact same spot */
            --Larry Wall in cons.c from the perl source code
#=============================================================================



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