Perl读写文件简单示例


!/usr/bin/perl -w
 use strict;
 
 #print "please input a string\n";
 #my $line = <STDIN>;
 #print $line;
 
 #wirte a file
 open(FH, ">aa.txt") or die $!; 
 print FH "hello\n";#向文件写入内容
 print FH "OK\n";
 
 close(FH);
 
 #open a file
 open(FH, "aa.txt") or die $!;
 my @f = <FH>;#将文件内容读出
 print @f;
 
 close(FH);

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年12月28日
下一篇 2023年12月28日

相关推荐