2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 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