in reply to General question about a haiku program

If your keys/indices are just consecutive numbers, an array (instead of the hash) might be a slightly more "natural" implementation... (not much of an issue, though).

... my $number = int(rand(5)); my @poems = ( "Even in Kyoto:hearing the cuckoo's cry--:I long for Kyoto.:Basho", "In this world:We walk on the roof of hell:Gazing at flowers.:Issa", "The old pond--:a frog jumps in,:sound of water.:Basho", "In the white plum blossoms:night to next day:just turning.:Buson", "Sick on a journey,:my dreams wander:the withered fields.:Basho", ); my ($line1, $line2, $line3, $author) = split ":", $poems[$number]; ...

Replies are listed 'Best First'.
Re^2: General question about a haiku program
by telemachus (Friar) on May 06, 2008 at 00:43 UTC
    A funny example of how stuck you can get seeing something from a particular angle. The hash is a relic of an earlier, more complex attempt, but once I settled on a hash, that part never changed back to an array. Thanks.