| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::Module::Authors; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 717 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 488 |  | 
| 4 |  |  |  |  |  |  | require 5.006; | 
| 5 |  |  |  |  |  |  | our $VERSION = 0.01; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | my @modules; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | # flag if we're in END { } | 
| 10 |  |  |  |  |  |  | my $in_end = 0; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub import { | 
| 13 | 0 |  |  | 0 |  |  | shift; | 
| 14 |  |  |  |  |  |  | unshift @INC, sub { | 
| 15 | 0 |  |  | 0 |  |  | my($self, $file) = @_; | 
| 16 | 0 | 0 |  |  |  |  | return if $in_end; | 
| 17 | 0 |  |  |  |  |  | push @modules, file2mod($file); | 
| 18 | 0 |  |  |  |  |  | return; | 
| 19 | 0 |  |  |  |  |  | }; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub file2mod { | 
| 23 | 0 |  |  | 0 | 0 |  | local $_ = shift; | 
| 24 | 0 |  |  |  |  |  | s/\.pm$//; | 
| 25 | 0 |  |  |  |  |  | s!/!::!g; | 
| 26 | 0 |  |  |  |  |  | return $_; | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub author_for { | 
| 30 | 0 |  |  | 0 | 0 |  | my $name = shift; | 
| 31 | 0 |  |  |  |  |  | my $module = CPAN::Shell->expand(Module => $name); | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | # ignore perl-core pragmas like overload, constant, strict ... | 
| 34 | 0 | 0 | 0 |  |  |  | return if !$module or | 
|  |  |  | 0 |  |  |  |  | 
| 35 |  |  |  |  |  |  | ($name =~ /^[a-z]/ and $module->cpan_file =~ m!perl-[\d\.]+\.tar\.gz$!); | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 0 |  |  |  |  |  | my $author = CPAN::Shell->expand(Author => $module->userid); | 
| 38 | 0 |  |  |  |  |  | return $author->name; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | END { | 
| 42 | 1 |  |  | 1 |  | 410 | $in_end = 1; | 
| 43 | 1 |  |  |  |  | 13392 | require CPAN; | 
| 44 | 1 |  |  |  |  | 396036 | local $CPAN::Frontend = 'Acme::Module::Authors::CPAN'; | 
| 45 | 1 |  |  |  |  | 8 | my %authors; | 
| 46 | 1 |  |  |  |  | 8 | for my $module (@modules) { | 
| 47 | 0 | 0 |  |  |  | 0 | my $author = author_for($module) or next; | 
| 48 | 0 |  |  |  |  | 0 | push @{$authors{$author}}, $module; | 
|  | 0 |  |  |  |  | 0 |  | 
| 49 |  |  |  |  |  |  | } | 
| 50 | 1 |  |  |  |  | 7 | local $" = ', '; | 
| 51 | 1 |  |  |  |  | 33 | print "This program runs thanks to:\n"; | 
| 52 | 0 |  |  |  |  |  | print "  $_ for @{$authors{$_}}\n" | 
|  | 0 |  |  |  |  |  |  | 
| 53 | 1 |  |  |  |  | 23 | for sort { @{$authors{$b}} <=> @{$authors{$a}} } keys %authors; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | @Acme::Module::Authors::CPAN::ISA = qw(CPAN::Shell); | 
| 57 | 0 |  |  | 0 |  |  | sub Acme::Module::Authors::CPAN::myprint { } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | 1; | 
| 60 |  |  |  |  |  |  | __END__ |