1、文件名前面没有”>”表示读文件
open(FILE,”~/test.txt”);
while(<FILE>)
{
chomp;
print “$_\n”;
}
close(FILE);
2、文件名前面有一个”>”表示写文件,并覆盖原有内容
open(FILE,”>~/test.txt”);
print FILE “Welcome to Perl\n”;
close(FILE);
3、文件名前面有两个”>”表示在这个文件后面追加内容
open(FILE,”>>~/test.txt”);
print FILE “Welcome to Perl again\n”;
close(FILE);