if you pass 3 separate arguments to open(), then your program will not compile with earlier perl interpreters!
Perl 5.6, which introduced the 3-argument open, was released more than 18 years ago. AFAIK people being stuck on a Perl <5.6 should be pretty rare nowadays.
The two-argument form of open will invoke external programs if the first or last character of the filename is a pipe (|). If the filename is user-supplied, this is a security risk! Also, the two-argument form doesn't let you specify I/O layers such as ':encoding(UTF-8)'. That's why the three-argument form is recommended nowadays.
make sure that my code will be backwards compatible
Your code won't run on a Perl <5.6 because warnings wasn't introduced until 5.6.
Notice that you do not need to use a variable for file handle. You can use numbers.
What advantage does this have? (Especially to a beginner?)
I am not sure if Perl automatically closes the open file handle when we call die()
It does.
In reply to Re^2: First attempt at bringing in file for input/output
by haukex
in thread First attempt at bringing in file for input/output
by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |