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


In reply to Re^7: Mail Merge with Word 2007 and Perl by cmiller2005
in thread Mail Merge with Word 2007 and Perl by cmiller2005

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.