Hey Friends,
I've been banging out a series of Perl scripts to support my LUG webpage. Tonight's quicke was a script that accesses a CGI-generated database of subscribed users, loads the email addresses supplies, and allows me to send a batch email out to everyone concerning meetings, etc. I think the way I did this was horribly inefficient, but I can't seem to dredge my thoughts right now for a better way. This is what I have:
use Mail::Send;
...time passes, children are born...
dbmopen(%CONTACT, "/httpd/userDBASE/contact", 0775)
or die "Couldn't open DBASE: $!";
for $member (keys %CONTACT) {
$CONTACT{$member} =~ /^\b(\S+)\b\s/;
$msg = new Mail::Send(
Subject => $subject,
To => $1);
open MSGBODY, "$file"
or die "Couldn't open $file: $!";
$fh = $msg->open;
while(<MSGBODY>) {
print $fh "$_";
}
$fh->close;
close(MSGBODY);
}
Can you see my problem? It lays in the fact that I have to open and close the filehandle containing the message to start at the beginning of the file for each mail send. Otherwise, only the first message has content, and all the others are blank! I can't seem to google for an action I can take to reset the 'file pointer' to the first character in the file. If I recall from years past, C++ has this capability.
Input is, as always, treasured.
~John
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.