Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Is there a problem with using barewords as filehandles ?

by eyepopslikeamosquito (Bishop)
on Jul 02, 2020 at 10:32 UTC ( #11118804=note: print w/replies, xml ) Need Help??


in reply to Re: Is there a problem with using barewords as filehandles ?
in thread Is there a problem with using barewords as filehandles ?

A review of PBP which praises Damian's rationale without quoting it, alas

If you are really keen you might be able to read at least part of the rationale by searching via google books, I just did that and here is some of Damian's rationale:

... using a bareword as a file handle causes Perl to store the corresponding input stream descriptor in the symbol table of the current package ... and if that symbol has already been used as a filehandle anywhere else in the same package, executing this open statement will close the previous file handle and replace it with the newly opened one ... bareword file handles are even more unreliable if there happens to be a subroutine of the same name currently in scope ...

For completeness, from Perl Best Practices here are all Perl Best Practices that mention bareword or filehandle:

  • 45. Don't use barewords.
  • 125. Don't use bareword filehandles.
  • 126. Use indirect filehandles.
  • 127. If you have to use a package filehandle, localize it first.
  • 130. Close filehandles explicitly, and as soon as possible.
  • 133. Slurp a filehandle with a do block for purity.
  • 136. Always put filehandles in braces within any print statement.
  • 246. Don't tie variables or filehandles.

  • Comment on Re^2: Is there a problem with using barewords as filehandles ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11118804]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2020-08-10 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (58 votes). Check out past polls.

    Notices?