# 读写文件.
#/usr/bin/perl -w
use 5.010; # Use 'say'.
# Read from file.
open F, "<data.txt"
or die "fail: open()";
my @arr = <F>; # Read all data to array.
close F;
# Write to file.
open F, ">res.txt" # Use ">>" if you want to append at end.
or die "fail: open()";
while (@arr) {
print F ($_."\n"); # Write to file.
}
close F;