2
eErrorT ChainCtrlExit (ChainCtrlT * pChainCtrl)
ChanT* ChainCtrlGetBitStreamChan (ChainCtrlT * pChainCtrl, 
char * name 
)
eErrorT ChainCtrlInit (ChainCtrlT * pChainCtrl, 
char * name, 
int instance, 
void * pOwner 
)

int SymContDecNamesCount = (sizeof(SymContDecNames)/sizeof(SymContDecNames[0]))
char* SymContEncNames[]
int SymContEncNamesCount = (sizeof(SymContEncNames)/sizeof(SymContEncNames[0]))

I want to extarct only function arguments ...that is 

输出我只需要在一行中提取函数定义参数

 ChainCtrlT * pChainCtrl
 ChainCtrlT * pChainCtrl, char * name 
 ChainCtrlT * pChainCtrl, char * name, int instance, void * pOwner  

我的代码

open(FILE, "< functions2.txt") or die $!;
open(FILE1, "> functions3.txt") or die $!;            

my @Array1=<FILE>;
foreach my $text (@Array1){
   $text =~ /\((.+)\)/;
   print FILE1 $text;
 }

但它正在将所有内容提取到新文件中。基本上是复制文件内容

4

1 回答 1

2
open(my $FILE, "<", "functions2.txt") or die $!;
open(my $FILE1, ">", "functions3.txt") or die $!;            


my $s = do { local $/; <$FILE>; };
while ($s =~ /^ \S+ \s+ \S+ \s* \( (.+?) \) /xsmg) {
  my $arg = $1;
  $arg =~ tr|\r\n||d;
  print $FILE1 "$arg\n";
}
于 2013-09-26T09:32:23.700 回答