Perl读写文件简单示例
发布时间:2016-12-28 来源:查字典编辑
摘要:!/usr/bin/perl-wusestrict;#print"pleaseinputastringn";#my$line=;#print...
!/usr/bin/perl -w use strict; #print "please input a stringn"; #my $line = <STDIN>; #print $line; #wirte a file open(FH, ">aa.txt") or die $!; print FH "hellon";#向文件写入内容 print FH "OKn"; close(FH); #open a file open(FH, "aa.txt") or die $!; my @f = <FH>;#将文件内容读出 print @f; close(FH);