Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: General question about a haiku program

by almut (Canon)
on May 06, 2008 at 00:12 UTC ( [id://684787]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://684787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-23 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found