Include mode in open() calls to prevent accidentally running a command. If the filename begins or ends with a pipe (|) symbol, Perl will pipe to or from a command, which is probably not what we want.
In the one- and two-argument forms of the call, the mode and filename should be concatenated (in that order), preferably separated by white space. You can--but shouldn't--omit the mode in these forms when that mode is < . It is safe to use the two-argument form of open if the filename argument is a known literal.
Here's the warnings from perlcritic that prompted this pull request (By the way, the Bareword file handle warning is harmless, I think):
Bareword file handle opened at line 233, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 233, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 285, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 285, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 439, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 439, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 504, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 504, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 898, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 898, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 925, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 925, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 988, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 988, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1069, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1069, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1096, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1096, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1128, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1128, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1155, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1155, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1189, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1189, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1421, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1421, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1700, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1700, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 1875, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 1875, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 2054, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 2054, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 2158, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 2158, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 2248, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 2248, column 5. See page 207 of PBP. (Severity: 5)
Bareword file handle opened at line 2333, column 5. See pages 202,204 of PBP. (Severity: 5)
Two-argument "open" used at line 2333, column 5. See page 207 of PBP. (Severity: 5)
Include mode in open() calls to prevent accidentally running a command. If the filename begins or ends with a pipe (
|
) symbol, Perl will pipe to or from a command, which is probably not what we want.According to
perldoc -f open
:Here's the warnings from
perlcritic
that prompted this pull request (By the way, theBareword file handle
warning is harmless, I think):