in reply to Perl formatting beginner

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.