Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
There are the same amount of variables in the one that shows the order.$_mergeFields = "##fname##;##lname##;##email##;##phone##;"; $_list_to_send_to = "Richard;Smith;myemail\@testmail.com;8005551212;|T +oby;Johnson;email2\@testmail.com;8885551212|Chanty;Perkins;another\@t +est.com;8665551212;";
Of course this email list is just for a business and when the emails go out, it is for the newsletter. So it is not for spam or anything, everyone is double opted in.$_message = qq~ Hello ##fname## how are you today? Hopefully your day is going well. I + am the list server for some company, blah blah blah, and I have list +ed your phone number as ##phone##. Well, here is all the data I have +for you: Name: ##fname## ##lname## Phone: ##phone## email: ##email## So I just wanted to say thank you for signing up yesterday to get emai +ls from us, and if you don't want to receive any more just click the +link below and we won't send any more out. blah blah blah blah~;
Something like that. That is not the way it should be done, but I don't know another way to do it. Do you? Can you point me in the right direction?$_field = 0; %_merData = (); %_mergedData = (); while($_mergeFields) { $_field++; ($_tempVar,$_mergeFields) = split /\;/, $_mergeFields, 2; $_merData{$_field} = $_tempVar; } $_field = 0; while($_list_to_send_to) { ($_tempVar,$_list_to_send_to) = split /\|/, $_list_to_send_to, 2; my $_tempMailMessage = $_message; my $_tempSubject = $_subject; while($_tempVar) { $_field++; ($_tempVar2,$_tempVar) = split /\;/, $_tempVar, 2; $_mergedData{$_field} = $_tempVar2; } foreach $key (key(%_merData)) { $_tempMailMessage =~ s/$_merData{$key}/$_mergedData{$key}/ig; $_tempSubject =~ s/$_merData{$key}/$_mergedData{$key}/ig; if($_merData{$key} =~ /email##$/) { $__to = $_mergedData{$key}; } } go_send_the_message($__to,$_tempSubject,$_tempMailMessage); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: merging two fields of data into one hash or array
by f00li5h (Chaplain) on Mar 24, 2007 at 04:22 UTC | |
|
Re: merging two fields of data into one hash or array
by bobf (Monsignor) on Mar 24, 2007 at 04:40 UTC | |
by f00li5h (Chaplain) on Mar 24, 2007 at 05:01 UTC | |
|
Re: merging two fields of data into one hash or array
by dReKurCe (Scribe) on Mar 24, 2007 at 14:11 UTC |