On Tue, Nov 09, 2010 at 04:53:35PM +0100, Abigail wrote: > On Tue, Nov 09, 2010 at 04:46:31PM +0100, demerphq wrote: > > > > My comment was inspired by the belief that the docs should not > > encourage people to use global variables when there are lexically > > scoped equivalents availble as a replacement. I think lexically scoped > > filehandles make sense because you wont get two pieces of code using > > the same handle name and colliding. Which encourages reuse of the > > code, which I think is generally a good idea. > > > Before 5.6, lexical scoped file handles were possible, but everyone > used globs, and the world didn't stop turning. Collision was so > infrequent, noone wanted to type the few extra keystrokes. It's only > when autovivifying handles came available everyone jumped on the "lexical > filehandle" bandwagon. > > It's not worth having a style fight over for.
No. But it might be if autodie could be persuaded to work on an implicit close when a lexical filehandle goes out of scope. That is, if these two snippets functioned identically: $ perl5.12.2 -Mautodie -E 'open my $f, ">", "/dev/full"; print $f 23' $ perl5.12.2 -Mautodie -E 'open my $f, ">", "/dev/full"; print $f 23; close $f' Anyone know what it would take to get that to work? Assuming autodie was in scope would allow much of the error checking code to be excised from the examples, thus allowing them to focus on the points they are trying to describe, whilst still espousing best practices. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net