#!/usr/bin/perl # Written by Jeff Borders # Last revised on 07/27/04 # Beginner Perl program to print labels by sheet or row. # Instruction for use: # 1. Change the address as needed. # 2. Run from command line and redirect to printer or file. # Example: ./labels.pl | lpr OR ./labels.pl >mylabels.txt # Standard disclaimer -- Use at your own risk! use strict; use warnings; my ( $name, $address, $citystatezip, $pages, $curr_row, $start_row, $end_row ); # Print label on Avery 5160 sheet # # of labels. (3x10) # # 3-line Address format # # Add 4th line to address, 30 char limit # $name="Your Name"; #<=== Change this! $address="Your Street"; #<=== Change this! $citystatezip="Anytown, OH 12345"; #<=== Change this! # Define starting and ending row # $curr_row=1; $start_row=1; #<=== Change this if you want to start printing on a different row. $end_row=10; #<=== Change this if you want to stop printing before row 10. # Define how many pages to print # $pages=1; #<=== Change this if you want to print more than more than one page. format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $name, $name, $name @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $address, $address, $address @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $citystatezip, $citystatezip, $citystatezip . while ( $pages > 0 ) { while ( $start_row <= $end_row ) { while ( $curr_row < $start_row) { # skip the row and add extra lines for top and bottom # print "\n\n\n\n\n\n\n"; $curr_row+=1; } write; $start_row+=1; $curr_row+=1; # extra lines for top and bottom # print "\n\n\n\n"; } $pages=$pages - 1; }