fileをopenします。
open(my $in, "<", "test.dat") or die("could not open file."); while(<$in>){ print $_; } close($in);
vagrant@vagrant-ubuntu-trusty-64:~/app$ cat test.dat
abc
def
ghi
123
456
789vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
abc
def
ghi
123
456
789
open(my $in, "<", "test.dat") or die("could not open file."); open(my $out, ">", "test.out") or die("could not open file."); while(<$in>){ print $out $_; } close($in); close($out);
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
vagrant@vagrant-ubuntu-trusty-64:~/app$ cat test.out
abc
def
ghi
123
456
789
書き込みですな。