基本文件操作和替换
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");
$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");
相关文章推荐
- File文件基本操作之二:java 替换指定文件中的指定内容
- 转:C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- Java IO-基本文件写操作
- Linux学习笔记--4.Linux 目录结构及文件基本操作
- Linux学习笔记--4.Linux 目录结构及文件基本操作
- C#对文件操作(基本的读写以及压缩和解压)
- 基本的文件操作
- ubuntu 基本命令之(文件操作命令)
- [整理学习]Hadoop基本文件操作命令
- git基本操作--删除文件和移动文件
- ASP FSO操作文件(复制文件、重命名文件、删除文件、替换字符
- 文件的基本操作(1)
- 文件的基本操作
- Day24-KindEditor基本使用和文件操作1
- PHP操作文件的一些基本函数使用示例
- Linux文件基本属性和操作
- (转载)Linux 学习记录 一(安装、基本文件操作)
- PHP文件的基本操作
- c++文件读写基本操作
- 文件基本操作(matlab)