in reply to General question about a haiku program

I would in any case use an array. An array of arrays would be remove the need of split.

Do you need the three lines as single variables? Otherwise just put them as one string and mark the line endings with "\n".

my $number = int(rand(5)) + 1; should be better my $number = int(rand(@poems)) + 1; and placed after my @poems = ( ... ).

Also putting the peoms in an extra file or in the __DATA__ section in an human readable format and then parsing them would make the code more maintainable and extentable.
You could use a format like this:

Line 1 Line 2 Line 3 Author Line 1 Line 2 Line 3 Author ...
then say $/ = '' to enable paragraph, not line, reading mode: (untested)
local $/ = ''; my @peoms = <DATA>; my $number = int(rand(@poems)) + 1; print $peoms[$number]; # or my ($line1, $line2, $line3, $author) = split "\n\s*", $poems[$number]; print " $line1\n$line2\n $line3\n\t$author\n"; __DATA__ Line 1 Line 2 Line 3 Author ...

Replies are listed 'Best First'.
Re^2: General question about a haiku program
by Anonymous Monk on May 06, 2008 at 12:23 UTC
    According to TAOUP, the record seperator is %%. We should stick to conventions for reasons outlined in the same book.