in reply to General question about a haiku program
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:
then say $/ = '' to enable paragraph, not line, reading mode: (untested)Line 1 Line 2 Line 3 Author Line 1 Line 2 Line 3 Author ...
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 |