in reply to Re^6: Mail Merge with Word 2007 and Perl
in thread Mail Merge with Word 2007 and Perl
Hello Again,
After getting some clarification on what I'm supposed to do I found that I am supposed to use PostScript::Simple only to create the letters from the text file I used previously. This is what I came up with:
use strict; use warnings; use PostScript::Simple; $|=1; my $file = 'C:\Users\Carl\Documents\AddressMergeTXT.txt'; open (INPUT, $file) or die ("Can't open file"); my $line; my $text; my $p = 1; while (my $newline = <INPUT>) { chomp $newline; my ($firstname, $lastname, $address, $city, $state, $zipcode, $blank1, + $blank2, $blank3, $blank4, $blank5, $blank6, $blank7, $barcode) = sp +lit('\t', $newline); $line = new PostScript::Simple (papersize => "Letter"); $line -> setfont("Arial,Bold", 10); $line -> text (430, 750, "Cogswell Cogs"); $line -> text(430, 740, "2234 W. Dale Ave."); $line -> text (430, 730, "San Antonio, TX. 77450"); $line -> text (430, 720, "722 - 423 - 7260"); $line -> text (40,700, $firstname); $line -> text (80, 700, $lastname); $line -> text (40, 690, $address); $line -> text (40, 680, $city.","); $line -> text (115, 680, $state."."); $line -> text (135, 680, $zipcode); $line -> setfont("USPSIMBStandard", 10); $line -> text (40, 670, $barcode); $line -> setfont("Arial,Bold", 10); $line -> text (40, 620, "Dear ". $firstname . ","); $text = &getLetter; $line -> text (40, 610, $text); $line -> output('C:\Users\Carl\Documents\testdata\file' .$p .'.eps'); $p += 1; } sub getLetter { my $txline; my $letterfile = 'C:\Users\Carl\Documents\NewLetter.txt'; open (INPUT1, $letterfile) or die ("Can't open file"); while ($txline = <INPUT1>) { return $txline; } } close (INPUT); close (INPUT1);
It works fine, even though the formatting and style probably sucks, up until I try to read in a form letter using the sub getLetter. It only reads in one line and then stops, thus only the first line of the file gets inserted into the letter. Can someone show me what I did wrong and how I can get the whole file loaded into the letter? Also, almost forgot, can someone tell me how to get the loop to skip reading in the headers on the text file? In other words, so the first letter created will not have First Name, Last Name as the recipient?
As always, any help appreciated
Carl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Mail Merge with Word 2007 and Perl
by roboticus (Chancellor) on Sep 18, 2014 at 23:56 UTC | |
by cmiller2005 (Initiate) on Sep 19, 2014 at 02:44 UTC | |
by roboticus (Chancellor) on Sep 19, 2014 at 03:15 UTC |