6.11. Open files in the old way

In old version of perl (before 5.6) we could not use scalar variabsles as file
handles so we used uppercase letters such as XYZ or INPUT, QQRQ or FILEHANDLE.

Also the function had only 2 parameters.

Example 6-10. examples/files/open_file_old.pl

#!/usr/bin/perl
use strict;
use warnings;

my $filename = "data.txt";
open(FH, $filename);
my $line = <FH>;
close FH;

open(FH, ">$filename");
print FH "data";
close FH;

Security problems.

Being global, difficult to pass as parameter to functions.


If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed