in reply to Re: First attempt at bringing in file for input/output
in thread First attempt at bringing in file for input/output
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: First attempt at bringing in file for input/output
by harangzsolt33 (Deacon) on Nov 01, 2018 at 03:24 UTC | |
by haukex (Archbishop) on Nov 01, 2018 at 12:01 UTC | |
by poj (Abbot) on Nov 01, 2018 at 12:52 UTC | |
by harangzsolt33 (Deacon) on Nov 06, 2018 at 00:46 UTC |