Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How do I test whether or not a file is writable?

by kiruthika.bkite (Scribe)
on Mar 18, 2010 at 10:56 UTC ( [id://829382]=note: print w/replies, xml ) Need Help??


in reply to How do I test whether or not a file is writable?

if(-f $name ) { if(!(-w $name)) { print "File '$name' doesn't have write permission\n"; } }

-f switch is used to check whether $name is file or not.
-w switch is used to test whether file has write permission or not.

Replies are listed 'Best First'.
Re: Answer: How do I test whether or not a file is writable?
by JavaFan (Canon) on Mar 18, 2010 at 14:34 UTC
    There's no point testing for both -f and -w. If the file doesn't exists (or if its existence cannot be determined), -w will return false. And if -w returns true, the file exists.
      Yes, but -w would also return true if the file is actually a writeable directory

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://829382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found