open(open_file,"test.txt") or "open file error";
while(
{
chomp;
print "$_\n";
}
close(open_file);
write data to file:
open(write_file,"test.txt") or "open file error";
my $data = "the data I want to write";
print write_file "$data";
close(write_file);