I'm more of a fan of stuffing the customer info into a hash

the stuff in <readmore> tags is not as interesting

#! /usr/bin/perl use strict; sub send_spam { print @_; } my $_mergeFields = "##fname##;##lname##;##email##;##phone##;"; my $_list_to_send_to = "Richard;Smith;myemail\@testmail.com;8005551212 +;|Toby;Johnson;email2\@testmail.com;8885551212|Chanty;Perkins;another +\@test.com;8665551212;";
# trim the # marks $_mergeFields =~ s/#//g; # list of field names my @field_names = split ';', $_mergeFields; # list of lines from the data my @records = split /[|]/, $_list_to_send_to; my $template = q[
dear ##fname## great prices in \|iaqra and molex watches available speial offer for you now exclusive offer sent to ##email##
]; foreach( @records ) { my $message = $template; # hash to fill with customer information my %customer_record; # use a hash slice to populate it, # we now have keys fname lname email and phone @customer_record{ @field_names } = split ';', $_ ; # neat, a one line templating engine. $message =~ s/##$_##/$customer_record{$_}/g for keys %customer_rec +ord; send_spam $customer_record{email}, $message; }
@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Update

  1. I won't ever use <readmore> tags for code folding again
  2. It's nice that my answer is in some way related to the question, as well as TIMTOWTDI

In reply to Re^2: merging two fields of data into one hash or array by f00li5h
in thread merging two fields of data into one hash or array by Anonymous Monk

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.