Larry Wall skribis 2005-04-21 15:50 (-0700): > There's one minor problem with -r -w $file, which is that it evaluates > right-to-left, which is going to surprise some people who think they > want to say > -e -r $file > when they really mean > -r -e $file
It doesn't have to, of course. The test can be postponed and delegated to the lexical first -X operator. A matter of letting -X behave differently in -X context than in any other context, I guess. > Now the interesting thing about the ~~ approach is that it naturally > lends itself to > given $file { > when :x {...} > when :r:w {...} > when :r(0) {...} > when :u | :g {...} > default: > } > I suppose it's a little bit rude to grab all the pairs for testing > against all the strings, so maybe we have to say > given $file.test {...} > $file.test ~~ :r&:w > or maybe > given $file.stat {...} > $file.stat ~~ :r&:w Perfect! > BTW, I'm assuming the $file is either $filename or $filehandle there. Which brings me to the following: can open please use the same kind of $file, so that open $filehandle just checks $filehandle's mode and returns $filehandle again? That way, every library function that accepts a filename automatically also accepts an open filehandle, which has a thousand and one benefits. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html