您的位置:首页 > 其它

基本文件操作和替换

2009-10-28 23:20 106 查看
$inputFile = "1.log";
$inTestPath = "testlist";
$outTestPath = "newTestList";

open(INF, "$inputFile") or die("cannot open $inputFile/n");
while(<INF>)
{
if(//.grxml$/)
{
chomp();
s////_/g;
s/grxml$/txt/;
$listFile = $inTestPath."//Grammar_".$_;
open(LSF, "$listFile") or print "cannot open $listFile/n";
$outFile = $outTestPath."//Grammar_".$_;
open(OUTF, ">$outFile") or print "cannot open $outFile/n";
}
elsif(/^/--------/)
{
close(LSF);
close(OUTF);
}
else
{
chomp();
s//(//|/;
s//s//|/;
s//)//;
$line = <LSF>;
@items = split(//s/[/, $line);
print OUTF $items[0]." [".$_."]/n";
print $items[0]." [".$_."]/n";
}
}
close(INF);
system("pause");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: