Skip to content

Instantly share code, notes, and snippets.

@fgabolde
Created January 28, 2014 09:16
Show Gist options
  • Save fgabolde/8664490 to your computer and use it in GitHub Desktop.
Save fgabolde/8664490 to your computer and use it in GitHub Desktop.
(unsuccessful) attempt to tally module usage
package EyeOfSauron;
use strict;
use warnings;
use 5.010;
use Carp;
# THE EYE SEES ALL, THE EYE KNOWS ALL
my %fellowship;
BEGIN {
*CORE::GLOBAL::require = sub { my $precious = $_[0];
$fellowship{$precious}++;
CORE::require(@_) };
}
END {
my @ringbearers = sort { $fellowship{$a} <=> $fellowship{$b}
|| lc $a cmp lc $b } keys %fellowship;
foreach my $precious (@ringbearers) {
warn sprintf("%s: %d\n", $precious, $fellowship{$precious});
}
}
use DateTime;
say DateTime->new;
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment