Acme-Module-Authors
view release on metacpan or search on metacpan
lib/Acme/Module/Authors.pm view on Meta::CPAN
package Acme::Module::Authors;
use strict;
require 5.006;
our $VERSION = 0.01;
my @modules;
# flag if we're in END { }
my $in_end = 0;
sub import {
shift;
unshift @INC, sub {
my($self, $file) = @_;
return if $in_end;
push @modules, file2mod($file);
return;
};
}
sub file2mod {
local $_ = shift;
s/\.pm$//;
s!/!::!g;
return $_;
}
sub author_for {
my $name = shift;
my $module = CPAN::Shell->expand(Module => $name);
# ignore perl-core pragmas like overload, constant, strict ...
return if !$module or
($name =~ /^[a-z]/ and $module->cpan_file =~ m!perl-[\d\.]+\.tar\.gz$!);
my $author = CPAN::Shell->expand(Author => $module->userid);
return $author->name;
}
END {
$in_end = 1;
require CPAN;
local $CPAN::Frontend = 'Acme::Module::Authors::CPAN';
my %authors;
for my $module (@modules) {
my $author = author_for($module) or next;
push @{$authors{$author}}, $module;
}
local $" = ', ';
print "This program runs thanks to:\n";
print " $_ for @{$authors{$_}}\n"
for sort { @{$authors{$b}} <=> @{$authors{$a}} } keys %authors;
}
@Acme::Module::Authors::CPAN::ISA = qw(CPAN::Shell);
sub Acme::Module::Authors::CPAN::myprint { }
1;
__END__
=head1 NAME
Acme::Module::Authors - Thank you CPAN authors
=head1 SYNOPSIS
use Acme::Module::Authors;
# in END phase it'll print out author names of modules used
( run in 0.663 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )