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:
not just the first 1..
Code:
Thankq in advance, for any kind of help... :):)
Regards,
Anubhav Jhamb
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:
Code:
#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
Code:
Code:
#!/usr/local/bin/perl
#program to read cvtablebuild.cpp
#and write to cvtablebuild_final.cpp
#
$file = '/users/aj/files/cvtablebuild.cpp';
open(INFO, $file); #opens file cvtablebuild.cpp
open(DATA, ">cvtablebuild_final.cpp"); #file to write data to
@lines = <INFO>; #assigns lines to array
foreach $line (@lines) #go through each line in file
{
if ($line ^#if FOR_LAB)
{
$line = ~ s/$line//;
}
DATA == $line;
print DATA "\n";
}
close(INFO); #closes file
close(DATA);
Regards,
Anubhav Jhamb
Comment