perl 打开和关闭文件

 1 #!/usr/bin/perl -w
 2 use strict;
 3 
 4 #print "please input a string
";
 5 #my $line = <STDIN>;
 6 #print $line;
 7 
 8 #wirte a file
 9 open(FH, ">aa.txt") or die $!;
10 
11 print FH "hello
";#向文件写入内容
12 print FH "OK
";
13 
14 close(FH);
15 
16 #open a file
17 open(FH, "aa.txt") or die $!;
18 my @f = <FH>;#将文件内容读出
19 print @f;
20 
21 close(FH);
原文地址:https://www.cnblogs.com/csu_xajy/p/4229270.html