Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Lexical filehandles have advantages beyond the fact that they close automagically when they fall out of scope. The truth of the matter is that in most cases it's fine to let input filehandles auto-close as they fall from scope, but probably a very good idea to explicity close filehandles that relate to output filehandles. Other reasons for using lexical filehandles include many of the same reasons that you would use lexical variables instead of package globals, plus it just looks cleaner passing lexical filehandlefs into function parameter lists than when typeglobs are used, IMHO. And it's nice to let filehandles fall under the watchful eye of strictures just like any other lexical variable; that's there to help write less buggy code. So use lexicals when appropriate not just because they auto-close, but for all the other benefits that lexical variables offer too. Dave In reply to Re: Catching errors in closing lexical filehandles
by davido
|
|