Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Function-frequency/Perl/function-frequency.pl
Normal file
16
Task/Function-frequency/Perl/function-frequency.pl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use PPI::Tokenizer;
|
||||
my $Tokenizer = PPI::Tokenizer->new( '/path/to/your/script.pl' );
|
||||
my %counts;
|
||||
while (my $token = $Tokenizer->get_token) {
|
||||
# We consider all Perl identifiers. The following regex is close enough.
|
||||
if ($token =~ /\A[\$\@\%*[:alpha:]]/) {
|
||||
$counts{$token}++;
|
||||
}
|
||||
}
|
||||
my @desc_by_occurrence =
|
||||
sort {$counts{$b} <=> $counts{$a} || $a cmp $b}
|
||||
keys(%counts);
|
||||
my @top_ten_by_occurrence = @desc_by_occurrence[0 .. 9];
|
||||
foreach my $token (@top_ten_by_occurrence) {
|
||||
print $counts{$token}, "\t", $token, "\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue