On 11-07-18 10:13 AM, Leon Timmermans wrote: > On Sun, Jul 17, 2011 at 11:39 AM, Matt S Trout<mst@shadowcat.co.uk> wrote: >> Oh, and I'd be totally happy with two arg being introduced. >> But *later*. Because in my experience most newbies read just >> far enough to get *an* open to work, and then just keep on >> using the first one they saw. >> >> In fact, the only exploit of a piece of code I wrote that I >> know of was because *I* stopped reading too soon and ended >> up with an unsafe 2 arg open. >> >> We recommend everybody does 'use strict' by default because >> it helps protect us from ourselves. The same applies to 3 >> arg open, especially in a tutorial document aimed at newbies >> who don't yet know enough to know when they're about to >> shoot themselves in the face. > > I agree. I've seen 2-arg open cause enough bugs (like this one: > https://rt.cpan.org/Ticket/Display.html?id=64504), I'd rather explain > them to use 3-args by default than explain when 2-args is safe and > when it isn't. > > Leon I considered whether to remove 2-arg open entirely. So far as I know, there is no case where it is needed over 3-arg, and it has problems that you and I are familiar with. That's not to say there are no such cases - I'm sure if there are then I wouldn't know about them. So, is there a reason to expend brainpower on knowing and assessing whether to use 2- or 3-arg open, or is 3-arg always suitable? If 3-arg is always suitable, then I'd like to hear the case for including 2-arg (and 1-arg!) in the tutorial. perlfunc should of course describe things as they really are, since it is a reference and not a tutorial. -MikeThread Previous | Thread Next