Re: Filehandle within foreach loop

2017-07-16 Thread David Mertens
Yes, and I think that gives us *two* reasons to always explicitly close filehandles. :-) David On Sun, Jul 16, 2017 at 8:00 AM, Shawn H Corey wrote: > On Sun, 16 Jul 2017 07:36:39 -0400 > David Mertens wrote: > > > Also note that lexical filehandles close when they go out of scope > > True but

Re: Filehandle within foreach loop

2017-07-16 Thread Shawn H Corey
On Sun, 16 Jul 2017 07:36:39 -0400 David Mertens wrote: > Also note that lexical filehandles close when they go out of scope True but you should always explicitly close your files. This gives you a chance to report any errors it had, have rather than silently ignoring them. -- Don't stop wher

Re: Filehandle within foreach loop

2017-07-16 Thread David Mertens
Even more readable: FILE: foreach my $file ( @files ) } ... last FILE if (some_condition); ... } Also note that lexical filehandles close when they go out of scope, except for the most recently "stat"ed file. Perl holds a reference to "the most recently stat-ed filehandle" in "the solitary