perl读文件第m到n行的实例

前端之家收集整理的这篇文章主要介绍了perl读文件第m到n行的实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#!/usr/bin/perl
use strict;
use warnings;


open (IN,"testdata.dat") or die;
open (OUT,">>./someRN.txt") or die;
my $i=1;


while (<IN>) {
chomp;
if ($i>=2&&$i<=4) { #..1000.2000........LZ...........
 print OUT "$_\n";
 }
 $i++;
}


seek(IN,0);


$i=1;
while (<IN>) {
chomp;
if ($i>=6&&$i<=8) { #..1000.2000........LZ...........
 print OUT "$_\n";
 }
 $i++;
}




close IN;
close OUT;

猜你在找的Perl相关文章