用于解析文本文件并输出文本文件的Perl代码 [英] Perl code for parsing a text file and output a text file
问题描述
此代码在Perl中(只是试用,未经测试)解析文本文件并输出到另一个文件。
用于删除不需要的行和用户想要的输出行到新文件。
问题是:
1这个脚本给出了空白行新文件。
2我必须从文本文件中删除整个分隔符(#if FOR_LAB)。
3.该工具应该能够解析文件,并删除FOR_LAB编码,而不影响周围的代码,即
我必须删除整个行序列:
Hi,
This code is in Perl (just a trial, not tested) to parse a text file and output to another file.
It is used to delete lines that are not required and output lines that the user wants, to a new file.
The problems are:
1 This script is giving blank lines in the new file.
2 I have to remove a whole delimitter (#if FOR_LAB) from the text file.
3.The tool should be able to parse the file, and remove FOR_LAB?ed code, with out affecting the surrounding code, i.e.
I have to remove whole of the sequence of lines:
推荐答案
这段代码在Perl中(只是试用,未经测试)解析文本文件并输出到另一个文件。
用于删除不需要的行和用户想要的输出行到新文件。 />
问题是:
1此脚本在新文件中给出空白行。
2我必须从文本文件中删除整个分隔符(#if FOR_LAB)。
3.该工具应该能够解析文件,并删除FOR_LAB编码,不影响周围的代码,即
我必须删除整个行序列:
#if FOR_LAB
DWORD dwSize = file.getFileSize();
DWORD dwMinFileSize = sizeof(CVTableCfgFileHeader)+
sizeof(CVTableCfgFileFracHdr)+ sizeof(CVTableCfgFileSigDesc);
if(dwSize< dwMinFileSize)
{
Error.Log(__ FILE __,CVT配置文件%s太短。,pszFileName);
返回false; //需要至少一个信号描述才有用
}
#endif
不仅仅是第一个..
< br $>
代码:
#!/ usr / local / bin / perl
#program读取cvtablebuild.cpp
#并写入cvtablebuild_final.cpp
#
Hi,
This code is in Perl (just a trial, not tested) to parse a text file and output to another file.
It is used to delete lines that are not required and output lines that the user wants, to a new file.
The problems are:
1 This script is giving blank lines in the new file.
2 I have to remove a whole delimitter (#if FOR_LAB) from the text file.
3.The tool should be able to parse the file, and remove FOR_LAB?ed code, with out affecting the surrounding code, i.e.
I have to remove whole of the sequence of lines:
#if FOR_LAB
DWORD dwSize = file.getFileSize();
DWORD dwMinFileSize = sizeof(CVTableCfgFileHeader) +
sizeof(CVTableCfgFileFracHdr) + sizeof(CVTableCfgFileSigDesc);
if (dwSize < dwMinFileSize)
{
Error.Log(__FILE__, "CVT config file %s is too short.", pszFileName);
return false; // need at least one signal description to be useful
}
#endif
not just the first 1..
Code:
#!/usr/local/bin/perl
#program to read cvtablebuild.cpp
#and write to cvtablebuild_final.cpp
#
file =''/ users / aj / files / cftablebuild.cpp'';
open(INFO,
file = ''/users/aj/files/cvtablebuild.cpp'';
open(INFO,
这篇关于用于解析文本文件并输出文本文件的Perl代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!