> The Avocado Avenger <sta...@io.com> wrote in news:3FC8DD72...@io.com:
> >
> > I would just like to thank you for not mentioning "turducken".
>
> You're most welcome. Especially since I don't know what that means
> any more than I know what FNARR means.
Fondling Nougatty Ayn Rand Readers.
> Don't tell me, don't tell me!
OOOPS! SORRY!
-----begin deacronymiser.pl---------------------
#!/usr/bin/perl
use strict;
use warnings;
my $acronym = $ARGV[0];
if (not defined $acronym)
{
die "usage: deacronymiser <ACRONYM>";
}
run($acronym);
sub run
{
my $acronym = shift;
$acronym = lc $acronym;
my @letters = split //, $acronym;
my $words_file = "/usr/dict/words";
my @words = ();
open WORDS, "<$words_file" or die "can't open $words_file: $!";
while(my $line = <WORDS>)
{
chomp $line;
$line = lc $line;
push @words, $line;
}
close WORDS or die "can't close $words_file: $!";
print uc $acronym, " = ";
while (my $letter = shift @letters)
{
next if $letter !~ m/[a-z]/;
my @match_words = grep {/^$letter/} @words;
my $word = @match_words[rand(@match_words)];
print ucfirst $word, " ";
}
print "\n";
}
__END__
-----end deacronymiser.pl---------------------
--
"I hate leonardo dacapprio I thin he is a little bitch and a whiner.
I would pay my life savinge to beable to kick his
ass!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" -- Mark Sharpe
http://beable.com/
: use strict;
Pussy.
--
___________________
rev...@revjack.net
> OOOPS! SORRY!
>
> -----begin deacronymiser.pl---------------------
I hope Beable doesn't mind, but I've modified the program so it will
load the dictionary and split it up once, then process more than one
acronym in the same command, with an option to generate multiple
expansions per acronym, without reloading or resegmenting the
dictionary.
--- begin example ---
$ deacronymiser.pl -n 3 ark perl
ARK = Ablution's Recipe Kiloton's
ARK = Aplenty Radiogram Kooking
ARK = Announcer's Rejoinder Kazoo
PERL = Pygmies Eve's Romano's Loped
PERL = Philanderer Enhance Rusting Loader
PERL = Pudgy Enthusiasm Reps Lifeworks
--- end example ---
--- begin code ---
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std ;
my (%option, $i, $acronym);
getopts("n:", \%option) ;
my $count = $option{n} || 1;
my %keyed_words = ();
load();
while (@ARGV > 0) {
$acronym = shift(@ARGV);
for ($i=0 ; $i < $count ; $i++) {
run($acronym);
}
}
sub load {
my $words_file = "/usr/dict/words";
my @words = ();
open WORDS, "<$words_file" or die "can't open $words_file: $!";
while(my $line = <WORDS>)
{
chomp $line;
$line = lc $line;
push @words, $line;
}
close WORDS or die "can't close $words_file: $!";
my ($word, $letter);
while(@words) {
$word = shift(@words);
$letter = lc(substr($word, 0, 1));
push( @{$keyed_words{$letter}}, $word );
}
}
sub run
{
my $acronym = shift;
$acronym = lc $acronym;
my @letters = split //, $acronym;
print uc $acronym, " = ";
while (my $letter = shift @letters)
{
next if $letter !~ m/[a-z]/;
my @match_words = @{$keyed_words{$letter}};
my $word = @match_words[rand(@match_words)];
print ucfirst $word, " ";
}
print "\n";
}
--- end code ---