Re: Newbie question about regular expression
- From: "Donal K. Fellows" <donal.k.fellows@xxxxxxxxxxxxxxxx>
- Date: Sun, 06 Apr 2008 16:28:11 +0100
Cameron Laird wrote:
How does the
if { [file exists $file] && [file readable $file] } {
...
you appear to have in mind not meet your requirements as a
"[c]heck if file exists and is readable"? It appears to me
that this fragment exactly fixes one of the things you say
you don't know how to fix.
Of course, he's better off doing that by trying to open the file for
reading, and catching the error when that fails. It's simpler, it's more
reliable (since [file readable] doesn't take into account all access
control schemes ever invented) and it doesn't have race conditions.
if {[catch {open $file} fd]} {
# File could not be opened; error message in $fd
} else {
# File exists, was readable, and is now open for business!
}
Donal.
.
- References:
- Newbie question about regular expression
- From: Ahmad
- Re: Newbie question about regular expression
- From: Cameron Laird
- Newbie question about regular expression
- Prev by Date: Re: Updating a variable value on a pattern matching -re in Expect
- Next by Date: Replica Hermes Handbags,Hermes Birkin Kelly***Bags,Hermes belts,Hermes wallets,replicas Hermes
- Previous by thread: Re: Newbie question about regular expression
- Next by thread: How to parse the first token (was: Newbie question about regular expression)
- Index(es):