Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback: Creating a mailing list using Perl

Feedback on: Creating a mailing list using Perl

Sent by Paul Bennett on October 26, 1998 at 06:30:37: - feedback #35
Overall:
What about Majordomo?

Removing addresses:
By truncating, rewinding, then rewriting the file, you're opening
the opportunity for a loss of data: what can you do if your
print fails? (You don't even check its return value!) Far better
to create the new list as a temporary file, close both files, then
rename the temporary on top of the master file at the end. (This
also saves you from the hugely inefficient reading of the whole
file into memory as you can process a line at a time.)

Your check for the user's address is bogus too:
Take:
$email = 'p.a.bennett@btinternet.com'
$line = 'poadbennett@btinternet.com'
Now check:
$line =~ /^$email/o
Did you perhaps mean:
$line =~ /^\Q$email/o
instead? (The \Q quotes the metacharacters in the rest of the RE.)
As for whether the ^ is necessary or not in the pattern, it certainly
is, or 'a.bennett@btinternet.com' unsubscribing would take me too!

Calling sendmail directly
I took a sharp intake of breath when I saw you opening the
SENDMAIL filehandle. A number of things come to mind:
1. Why aren't you using a CPAN module (I'm sure there's
one to send mail somewhere)
2. Why are you passing the email address on the command line?
Imagine this address: ';rm -rf *'
Far better to call 'sendmail -t' and write the addresses on STDIN.
3. Why send a separate message for each user? Why not
group them together using the Cc: or Bcc: field? (Or for that
matter, why not use Majordomo?)

Also... a mistake on js049:
You refer to W3C's address as "http://www.w3.com" - it should
be "http://www.w3.org". Big difference.

Paul.

Sent by Michael McLaughlin on August 23, 1999 at 14:32:01: - feedback #403

Worth:
Very worth reading

Length:
Just right

Technical:
Just right

Comments:
Jason,

I have been working through your excellent series of articles on Perl/CGI. They are the best on the web.

I think there may be an error in your article "creating a mailing list using Perl".

For removing names from the list, you suggest opening the file in >> mode.

I found that this did not allow me to read in the names into @emailfile
I had to open FILE in read mode, read in the names, close FILE.
Then open in >> mode. Truncate and do the regexp.
There is probably a more eleganyt way to do this, but it seems to work OK.

What do you think?

By the way -- willl you be doing any articles about using CGI with database files? I suppose this is the next step up from using simple text files with data in them.

Michael McLaughlin
Media Foundry
England
www.media-foundry.com





Sent by Jeena on October 28, 1999 at 02:39:35: - feedback #540

Worth:
Very worth reading

Length:
Just right

Technical:
Just right

Comments:

Hi,

The article was helpful, but I have a doubt. How can we get back the exit status of the sendmail program in PERL?
Sendmail returns status like EX_NOUSER, EX_NOHOST etc. I want to use these values after I send the mails.
Please help.

Thanx,

Jeena.






Sent by Jim Freeman on June 11, 2000 at 11:48:08: - feedback #1353

Worth:
Very worth reading

Length:
Just right

Technical:
Just right

Comments:
can you tell me where I could find some help on dynamically generating HTML mail? I have tried what appears to be the proper mime and content type tags - but they are consistently interpreted as the body of the email, not as control information. BTW: I know my email client is capable of displaying html email.


Sent by Thanos Chatziathanassiou on September 08, 2000 at 05:01:09: - feedback #1728

Worth:
Worth reading

Length:
Just right

Technical:
Not technical enough

Comments:
Good article, but I think that using the diamond operator is quite faster and more efficient, especially for larger files. (ie

while (<FILE>) {
..do something ...
}

instead of
@lines = <FILE>;
foreach (@lines) {
..do something ...
}

Also, flock() is 'blocking' by default, so there really is no need to die(). It will just stand there, waiting for the file to be released. Unless a proccess has crashed and kept the file open (in which case it will probably already have been corrupted), it should be available moments later.

Other than that, it's ok...



©2018 Martin Webb