On Wed, 20 Jul 2011 08:53:20 +0200, Tom Christiansen <tchrist@perl.com> wrote: >> * David Golden <xdaveg@gmail.com> [2011-07-18 22:40]: >>> As Tom points out, there is no problem with 2-arg open if *you* >>> control all the arguments and know what you're doing. The >>> rationale for 3-arg open is (IMO) that it's less error-prone. > >> 2-arg open is also useful when you don’t *want* to control all >> inputs, such as giving a caller the option to ask for transparent >> decompression by piping from zcat instead of reading from a file. > > > No, two-arg open is perfectly fine here: > > open(STDOUT, "> /dev/null") > > It's all constants. We know exactly what's going on. > > And > > open(STDOUT, "> $fn") > > is only marginally worse, because of the whitespace issues. > > --tom > Recently i had a discussion about -w in the hashbang, where my position was: Do not use it, unless you perfectly and exactly know how to use it and what it does to your program. Quite a few people pointed out good uses for it, but they all overlooked that the context of the discussion was "complete newbies". There is no way they can make an educated decision on whether to use it or not; so the correct advice would be "don't use it, stick with 'use warnings;'". I seem to see something similar happening here. 'perlopentut' is a tutorial, a teaching aid that guides by example. As such i think it is fair to assume that it is meant to be aimed at newbies. Now, since the first draft of this was posted, you've been giving examples that really are perfectly fine. Though it is important to note that your examples are only fine for the exact textual representation they are, and not for a class of uses. Meaning that in order to be able to use them correctly one has to be able to correctly identify the class of use they belong to. People who cannot do that are likely to have things like this happen: https://rt.cpan.org/Ticket/Display.html?id=64504 I do not think the intended audience of perlopentut has enough knowledge and experience to be able to do that. So while your examples are correct, they seem to miss the intended audience. What say you? -- With regards, Christian WaldeThread Previous | Thread Next