dhendrix has asked for the wisdom of the Perl Monks concerning the following question:

use strict; use warnings; my $boss_first_name = "Penelope"; my $boss_last_name = "Creighton-Ward"; my $butler_first_name = "Aloysius"; my $butler_last_name = "Parker"; my $field_width = 15; print '|', ' 'x$field_width, '|', ' 'x$field_width, "|\n";
.

How can I change this program so it will print out a line containing the boss's first and last names in the first field and the butler's first and last names in the second field? I need the output to look like this

| | | |Penelope |Aloysius Parker| |Creighton-Ward | |

Replies are listed 'Best First'.
Re: Print in box syntax
by Corion (Patriarch) on Jul 07, 2015 at 13:33 UTC

    Most likely, your course material covers this.

    What does your program currently output? Have you read print?

Re: Print in box syntax
by stevieb (Canon) on Jul 07, 2015 at 13:30 UTC
      thanks sir this is completely new to me

        Your ending <code> tag needs to be </code>.

        It is also helpful to enclose your output (and input, if you had had any) in <code>...</code>. This will preserve the formatting and let us see the spacing properly.

Re: Print in box syntax
by BillKSmith (Monsignor) on Jul 07, 2015 at 14:43 UTC

    Others have pointed out that you must ask your question "effectively". Let me point out a few of the details you must address. Your text, code, and examples must be clearly consistent.

    Your single example does not convey your definition of "field". (Or how to count them.) Your code suggests fixed length fields. Your example appears to be CSV format.

    Your example appears to contradict your text. (How can your boss's first and last name be in the same "field" when they are not even close to each other in the example?

    Your code does not print any names at all.

    Bill
Re: Print in box syntax
by Laurent_R (Canon) on Jul 07, 2015 at 14:08 UTC
    Please use <code> and </code> tags both for the code snippet and for the desired output format.
Re: Print in box syntax
by Monk::Thomas (Friar) on Jul 07, 2015 at 22:00 UTC
    You could
    1. create an array with 9 empty fields
    2. populate fields 4,5 and 7 with the correct values
    3. join() the array fields into a string using pipe symbols
    4. print the resulting string

    Implementation left to the reader. You can ask if you're having problems with a particular detail, just don't expect to get the complete code handed on a silver plate. ;)

      the array should have 10 fields, because there are 9 pipe symbols :-)

      I think the OP wants something similiar to
        fmt -15 | pr -2 -s"|"
      however, that's pure supposition, although based upon the HTML source, which reveals

      | | | |Penelope |Aloysius Parker| |Creighton-Ward | |
      Update: this means, fields 3,6, and optionally 9 should contain newlines
Re: Print in box syntax
by 1nickt (Canon) on Jul 07, 2015 at 18:21 UTC

    All true, your question is a dog's breakfast.

    But I upvoted for the Thunderbirds reference :-)

    Remember: Ne dederis in spiritu molere illegitimi!