Acme-Scurvy-Whoreson-BilgeRat-Backend-insultserver

 view release on metacpan or  search on metacpan

lib/Acme/Scurvy/Whoreson/BilgeRat/Backend/lala.pm  view on Meta::CPAN

package Acme::Scurvy::Whoreson::BilgeRat::Backend::lala;

$VERSION = '1.0';

use warnings;
use strict;

use base 'Acme::Scurvy::Whoreson::BilgeRat';

=head1 NAME

Acme::Scurvy::Whoreson::BilgeRat::Backend::lala - generate insults in the style of one of London.pm's bots

=head1 SYNOPSIS

    use Acme::Scurvy::Whoreson::BilgeRat;

    my $insultgenerator = Acme::Scurvy::Whoreson::BilgeRat->new(
        language => 'lala'
    );

    print $insultgenerator; # prints a piratical insult


=head1 DESCRIPTION

The IRC channel #london.pm on the rhizomatic network used to have a bot, 
called Lala, that would insult you in her own inimitable style.

This is a backed for C<Acme::Scurvy::Whoreson::BilgeRat> that reproduces that style.

It's useless to anyone but this one particular project I'm working on. 
But since when has that stopped me?

=head1 AUTHOR

Simon Wistow <simon@thegestalt.org>

based on code by

Jonathan Stowe <jns@gellyfish.com>

=head1 COPYRIGHT

Copyright 2005, Simon Wistow

Distributed under the same terms as Perl itself.

=head1 SEE ALSO

http://london.pm.org

=cut



sub new {
	my $class = shift;
	
	my (@noun, @adj1, @adj2);

	my $pos = tell DATA;
    while(<DATA>) {
        chomp;
        next if /^\s*$/;


        my ($adj1,$adj2,$noun) = split;

        push @adj1, $adj1;
        push @adj2, $adj2;
        push @noun, $noun;
    }

    seek DATA, $pos,0;


	return bless { noun => \@noun, adj1 => \@adj1, adj2 => \@adj2 }, $class;
}

sub generateinsult {
	my $self  =shift;
	my @adj1  = @{$self->{adj1}};
	my @adj2  = @{$self->{adj2}};
	my @noun  = @{$self->{noun}};

  	return $adj1[rand @adj1] . " ";
           $adj2[rand @adj2] . " " .
           $noun[ rand @noun];
}



( run in 3.818 seconds using v1.01-cache-2.11-cpan-54e63673c56 )