Hello,

Yes, I do recommend using a CSV module ro read your data. And yes, I recommend against format, but it is an easy (though very tedious), visual way to lay out "page oriented" output.

Caveat: When using format, you need to use a monospaced font for your output.

Caveat: This is really ugly. (Because format is really clunky)

My example, below, is very simple. Even with format, it can be done better.

(Also, I'm very probably forgetting something, here. It has been years since I last used format.)

I am guessing you intend to print labels. Depending on print size and line spacing, you can usually fit 3 or 4 lines of 30 to 40 characters. You will have to determine this yourself.

First, use sprintf to format the lines of each label:

my $adr01 = sprintf("%16.16s, %10.10s %1.1s\r",$last,$first,$mi); $adr01 .= sprintf("%30.30s\r%30.30s\r",$adr1,$adr2); $adr01 .= sprintf("%16.16s %2.2s %10.10s",$city,$state,$zip);

Then you can place the labels on the page using format:

format LABEL_PAGE = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr01,$adr02,$adr03 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr01,$adr02,$adr03 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr01,$adr02,$adr03 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr01,$adr02,$adr03 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr04,$adr05,$adr06 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr04,$adr05,$adr06 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr04,$adr05,$adr06 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<< +<<<<<<<<<<<<<<<<<<<<<<<< $adr04,$adr05,$adr06 Insert additional rows to fill page. .

You will need to test the spacing and probably adjust the output character size and line spacing. You will need to use a monospaced font for printing.

As I said, this is really clunky, so is really ugly.


In reply to Re: Perl formatting beginner by RonW
in thread Perl formatting beginner by Anonymous Monk

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.