私は課題を扱っていますが、Perlは本当に初めてです。よくわからない。これらの3種類のファイル(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