This is the second mention of a PerlMonks entry from last week I wanted to do...
Putting it briefly, I expected that a command like the one in the subject would open()
a file "in memory" with the appropriate layer. Simply, it's not so: if you specify a layer, then the reference will be stringified and interpreted as a file name. Not too much of a problem: you can still use an explicit binmode()
on the handle. Only, it's by all means a confusing behaviour, and I don't see how anyone could contradict me. Point is, the docs never say "if the third argument is a scalar reference, then it is opened as in memory file." Actually the feature is only described by two examples, both referring to '>'
mode. Indeed other ones work too, but not if layers are specified. All in all I would say that the documentation could be clearer. But more importantly, although I am aware that Perl (5) deviates often enough from orthogonality, I don't see much usefulness in it doing so in this case and I would prefer it to be consistent by behaving as (I) expected.
Incidentally, Anno mentioned another situation in which it would be nice to have a scalar reference implicitly refer to a file "in memory", namely in connection with the magical ARGV
filehandle, that is if you put one such reference in @ARGV
. Indeed if such a beast did exist than that handle would be even more magic!
Now that I think of it, it would also be nice if @ARGV
supported typeglob references to be interpreted as filehandles too, for even more magic. Not something for which I feel a compelling need, but not bad to have, I guess... (I can imagine a few situations in which it would be useful.) Of course this has not much to do anymore with the subject of this post...
Hehe I know...
blazar on 2007-04-02T15:52:58
But unfortunately expertise lacks or... would complaining like Abe count as a patch?