Acme-CPANAuthors-Not
view release on metacpan or search on metacpan
--- #YAML:1.0
name: Acme-CPANAuthors-Not
version: 0.01
abstract: We are not CPAN authors
license: perl
author:
- Steve Fink <sfink@cpan.org>
generated_by: ExtUtils::MakeMaker version 6.42
distribution_type: module
requires:
Acme::CPANAuthors: 0.01
Test::More: 0.47
Test::UseAllModules: 0.09
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
lib/Acme/CPANAuthors/Not.pm view on Meta::CPAN
package Acme::CPANAuthors::Not;
use Acme::CPANAuthors::Utils qw(cpan_authors);
use strict;
use warnings;
our $VERSION = '0.01';
our $HOWMANY;
BEGIN {
$HOWMANY = "WHAT DO YOU GET IF YOU MULTIPLY SIX BY NINE?";
}
lib/Acme/CPANAuthors/Not.pm view on Meta::CPAN
$name .= $fragments->[rand(@$fragments)] . " ";
}
chop($name);
return $name unless exists $table->{existing}{$name};
}
}
sub _generate {
# Generate a lookup table of valid CPAN ids to avoid
my $authors = cpan_authors();
my %ids;
$ids{ $_->pauseid } = 1 foreach ($authors->authors);
# Compute how many invalid ids to return
my $howmany = $HOWMANY;
for ($howmany) {
s/(\w+)/{ ONE => 1,
TWO => 2,
THREE => 3,
FOUR => 4,
FIVE => 5,
SIX => 6,
lib/Acme/CPANAuthors/Not.pm view on Meta::CPAN
# to come up with vaguely sensible ids
my ($length_freq, $letter_freq) = _freq_table([ keys %ids ]);
# Generate $howmany random ids
my @invalid_ids;
while (@invalid_ids < $howmany) {
my $id = _random_id($length_freq, $letter_freq);
push @invalid_ids, $id unless exists $ids{$id};
}
# Pick a name for each author
my $name_table = _name_table([ map { $_->name } $authors->authors ]);
return map { $_ => _pick_name($_, $name_table) } @invalid_ids;
}
use Acme::CPANAuthors::Register(_generate());
1;
__END__
=head1 NAME
Acme::CPANAuthors::Not - We are not CPAN authors
=head1 DESCRIPTION
This class provides a hash of nonexistent CPAN authors' Pause ID/name to
Acme::CPANAuthors.
=head1 INTERNALS
While I was tempted to use a tied hash to provide an infinite set of
nonexistent authors, I decided against it because it wouldn't fit in
with Acme::CPANAuthors very well (it listifies the hash). So I went
for randomness instead.
Oh, and this module works way too hard for what it does.
=head1 MAINTENANCE
If you are a CPAN author and are listed here, there's a bug. Please
fix it.
=head1 AUTHOR
Steve Fink, E<lt>sfink at cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008 by Steve Fink.
( run in 0.826 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )