前端之家收集整理的这篇文章主要介绍了
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);