Perl Quiz-of-the-Week #1

Mark-Jason Dominus <[email protected]> Wed, 16 Oct 2002 14:49:19 -0400
Newsgroups gmane.comp.lang.perl.qotw.quiz-of-the-week
Organization Plover Systems
Message-ID <[email protected]>
Write a function, 'center', whose argument is a list of strings, which
will be lines of text.  'center' should insert spaces at the beginning
of the lines of text so that if they were printed, the text would be
centered, and return the modified lines.

For example,

        center("This", "is", "a test of the", "center function");

should return the list:

        "     This", "      is", " a test of the", "center function"

because if these lines were printed, they would look like:

             This
              is
         a test of the
        center function

----------------------------------------------------------------

Some notes:

 * I'll post an example solution here on Monday.

 * perl-qotw will only carry the quizzes and solutions.  Discussion,
   remarks, comments, and soforth should go to
   [email protected].  To subscribe to that list, send mail
   to [email protected].

 * I'd like to request that nobody post any sample solutions or other
   spoilers to the discussion list until at least Saturday.

 * Even after Saturday, any solutions or other spoilers should always
   be marked with the word SPOILER in the subject line, so that other
   people won't see them by accident.

 * If you'd like to contribute a quiz question, send it to me.

 * I will set up a web archive eventually.  In the meantime, old
   messages are always available by email.  Send a message to
   [email protected] (or to
   [email protected]) for instructions.

Thanks.