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 ...

In reply to Re: General question about a haiku program by mscharrer
in thread General question about a haiku program by telemachus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.