Acme-CPANAuthors-Not

 view release on metacpan or  search on metacpan

lib/Acme/CPANAuthors/Not.pm  view on Meta::CPAN


    for my $name (@$existing) {
        my @parts = $name =~ /(\w+)/g;
        @all{@parts} = ();
    }

    @all{qw(Fudd Crazy Evil Underhill Mechanical)} = ();

    my %lookup;
    $lookup{$_} = 1 foreach (@$existing);
    return { existing => \%lookup, fragments => [ keys %all ] };
}

sub _pick_name {
    my ($id, $table) = @_;

    # Currently ignoring the id. Probably ought to do something clever
    # with it.

    # Surprisingly, simple exponential decay doesn't give a sharp
    # enough cutoff. So I'll go doubly exponential.
    my $name_pieces = 1;
    $name_pieces++ while (rand() < 0.7**$name_pieces);

    my $fragments = $table->{fragments};
    while (1) {
        my $name;
        foreach (1 .. $name_pieces) {
            $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();



( run in 1.188 second using v1.01-cache-2.11-cpan-b16cb0d3907 )