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

Feedback on: Creating a mailing list using Perl, October 26, 1998 at 06:30:37:

You are here: irt.org | About | Feedback | 35 [ previous next ]

Feedback on:
Creating a mailing list using Perl

Sent by
Paul Bennett on October 26, 1998 at 06:30:37: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.

Other feedback on 'Creating a mailing list using Perl' - show all

©2018 Martin Webb