#!/usr/bin/perl #ode to a random number v0.2 open my $dict, "; my $count = 70*rand(); { use integer; $count /= 1; } my $syllables = 0; for ( 'a', 'e', 'i', 'o', 'u' ) { $vowel{ $_ } = 1; } for ( 0..$count ) { my $ptr; my $thissyll; do { $ptr = rand() * $#words; $thissyll = Syllables( $words[$ptr] ); } until ( $words[$ptr] eq lc( $words[$ptr] ) and ((20-$syllables-$thissyll) >= 0 )); $syllables += $thissyll; chomp $words[$ptr]; unless( $_ ) { $words[ $ptr ] =~ /^(.)(.*)$/; my $b = uc( $1 ); $words[$ptr ] = $b . $2; } if ( $_ < $count ) { print $words[$ptr]; if ( $syllables >= 20 ) { print ";\n"; $syllables = 0; } else { print ' '; } } else { print $words[$ptr] . ".\n"; } } sub Syllables { my $word = shift; chomp $word; my $lv = 0; my $tv; my $syll = 0; for my $letter( split '', $word ) { $tv = $vowel{ $letter }; ( $tv == $lv ) or $syll++; $lv = $tv; } return $syll; }