第一章:读取文件一行IO::File

 1 #!c:\perl\bin\perl.exe
 2 use IO::File;
 3 #读取一行
 4 my $fd = IO::File->new('perl.txt');
 5 my $one_line = <$fd>;
 6 print $one_line;
 7 $fd->close;
 8 
 9 #写入数据
10 my $wfd = IO::File->new(">> readme.txt");
11 print $wfd "I love Perl!
";
12 print $wfd "And you?
";
13 $wfd->close();
14 #>>为追加, >为复盖写入
原文地址:https://www.cnblogs.com/perl6/p/6417365.html