Randal this, randal that. Let's face it, everyone here is too busy pointing fingers and shifting blame rather than actually trying to do something FUN with perl.
So let me be the one who starts with the FUN again, in the hope others will follow.
Here's a FUN little program which uses a slightly adapted schwartzian transform to generate comments from various categories provided some conditions are true.
Allthough I can't tell you how I got the idea for this program, I'd like to stress it's intended as FUN!
-kane
no strict 'truth';
### the 'variables' in the world of $has_been
my $has_been = { ego => 1000, skill => 50 };
### well.. it's... 'life' ###
my $life = 500;
### our automatons ###
my %groupies = (
'8-year-old' => { iq => 60 },
'family dog' => { iq => 80 },
'Matt Wrong' => { iq => 50 },
'l33t sk1llz' => { iq => 70 },
'hoo[tk]ers' => { iq => 40 },
);
### the universal measure of intelligence ###
my $midget = { shoesize => 20 };
while ($has_been->{'ego'} > $life) {
for my $automaton ( keys %groupies ) {
chop $groupies{$automaton}->{'iq'}
until $groupies{$automaton}->{'iq'} < $midget->{'shoesize'};
printf "%12s says: %-50s\n",
$automaton, babble( type => 'random', content => 'suck
+-up');
sleep 1;
}
}
sub babble {
my %args = @_;
### known catetegories ###
my $cat = {
'mindless' => 0,
'suck-up' => 1,
'defensive' => 2,
};
### responses likely given by $automaton when $has_been is
### publicly critisized.
### the 2nd element is a string of scored in the 3 different
### catagories in $cat
my $rants = [
[q|His sense of self-importance is plainly justified|, 453],
[q|Why should he have to temper his personality to others sens
+ibilities?|, 345],
[q|He can ridicule me, because He Is Right|, 514],
[q|More, please!|, 122],
[q|*nod nod nod nod nod nod*|, 231],
];
### now to order the reply by score in the catogory requested ###
### this calls for a schwartzian transform ;) ###
my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] }
map { [ $_, substr ($_->[1], $cat->{$args{'content
+'}}, 1) ] } @$rants;
if ($args{'type'} eq 'random') {
return $sorted[int rand @sorted][0];
} elsif ( $args{'type'} eq 'most' ) {
return $sorted[$#sorted][0];
} else {
return $sorted[0][0];
}
}