我正在处理一项任务,而且我对 Perl 真的很陌生。真的不是很懂。你们能指导我提取这三种文件(C、C++ 和 Java)的注释和函数名吗?
我已经尝试过这个:
use strict;
use warnings;
use File::Basename;
use File::Find;
use File::Slurp;
use Regexp::Common qw /comment/;
my $fileName = "a.java";
my $wordsIn = "";
my $wordsIdentifier="";
my $numRemoved = 0;
#$wordsOut = `xscc.awk extract=comment prune=copyright $fileName`;
$wordsIn = read_file($fileName) ;
# Find all matches of comments, and put them into @arr
my @arr = $wordsIn =~ m/$RE{comment}{Java}/g;
my $wordsOut = join(" ", @arr);
print "Comments:\n";
print $wordsOut;
$wordsIn =~ s/$RE{comment}{Java}//g;
print "Identifiers:\n";
print $wordsIn;
它完美地获得了评论(即使我不知道如何!),但是为了检索标识符和方法名称,我应该为 $RE{comment}{Java} 做什么
问候 Ehsan