Perl学习笔记
open TXT,">t4.txt";
print TXT "你下辈子做猪。";
open TXT,">>t6.txt";
print TXT "你是你是你是";
close TXT;
close TXT;
close TXT;
open TXT,"t4.txt";
my $w=<TXT>;
open TXT,"t6.txt";
my $d=<TXT>;
open TXT,">>t5.txt";
print TXT "$w";
print TXT "$d";
close TXT;
close TXT;
close TXT;
8、将t1.Txt、t2.txt、t3.txt三个文件中的内容用其他数据代替,然后将t1.txt和t2.txt里面的内容放入t3.txt中。
#!/urs/bin/perl
open a,">t1.txt";
print a "2013";
open b,">t2.txt";
print b "0830";
open c,">t3.txt";
print c "芜湖";
close a;
close b;
close c;
open c,">>t3.txt";
open a,"t1.txt";
open b,"t2.txt";
print c "\n".<a>."\n";#.是连接符,print c <a>;是直接连接不要换行。
print c <b>."\n";
close a;
close b;
close c;
9、合并文件后删除不要的文件。
在8代码后加入如下代码:
unlink<t1.txt>;
unlink<t2.txt>;
或者
Unlink<t1.txt>,<t2.txt>;