I've written a trivial program to print avery labels.  One that allows
me to specify how many rows to print (when I don't need 30 labels).

The problem is that I don't want to print a blank line on a 3 line
label.

I thought the "~" would take care of this in format, but no.  I've also
tried using printf without a format block, but couldn't figure out how
to left justify the strings.

My label format  is:

Name
(PO Box or Suite, if needed)  <--this is the blank line.
Address
City, State  Zip

Below is my program.

!/usr/bin/perl

use strict;
use warnings;

my (
$name,
$address,
$address2,
$citystatezip,
$label_rows,
$skip_rows,
$line_feeds,
);

$line_feeds="\n\n\n\n";

# Print label on Avery 5160 sheet
# of labels.  (3x10)

# Skip missing labels where I've already
# printed.
print "\nEnter How Many Rows to Skip: ";
chomp($skip_rows = <STDIN>);

# Only print the rows I need.  Save the rest
# for another run.
print "\nEnter How Many Rows to Print: ";
chomp($label_rows = <STDIN>);

print "\nEnter recipient name: ";
chomp($name=<STDIN>);

print "\nEnter address: ";
chomp($address=<STDIN>);

print "\nEnter P.O Box or Suite [None]: ";
chomp($address2=<STDIN>);
# Check for a PO Box or Suite Number
if ($address2=~/\w/) 
        {
                $line_feeds="\n\n\n"
        }
print "\nEnter city, state  zip: ";
chomp($citystatezip=<STDIN>);


# Print Format Definitions

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$name,                          $name,                          $name
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
~ $address2,                    $address2,                      $address2
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$address,                       $address,                       $address
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$citystatezip,                  $citystatezip,                  $citystatezip
.

while ( $label_rows > 0 )
        {
                if ( $skip_rows > 0 ) 
                        {
                                $skip_rows=-$skip_rows; 
                        }
                else    {
                        write;  
                        $label_rows=$label_rows - 1;
                        }       
                print $line_feeds;
        }
        



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to