Gregory Sutter <gsutter(_at_)ugems(_dot_)psu(_dot_)edu> writes:
# This section takes lists of domains, concatenates them and checks against
# the full list. It requires a long LINEBUF but makes overall better sense
# because perl is only invoked once per mail rather than multiple times.
DOMAINS=`cat $PMDIR/domains/* | perl -p0e 's/\012(.)/\|$1/g; s/\./\\./g;
s/\015//g; s/\|{2,}/\|/g'`
...and our next nominee for the "pointless use of 'cat'" award is Greg
Sutter...
However, it would be even more efficient to instead use only use perl
once per change to the domains file(s). Everytime you change any of
the files in $PMDIR/domains, run the command:
perl -p0e 'BEGIN{print "DOMAINS=";} s/\012(.)/\|$1/g; s/\./\\./g;' \
-e 's/\015//g; s/\|{2,}/\|/g'` $PMDIR/domains/* \
>$HOME/.procmailrc.domains
(If you don't have perl5 then the BEGIN{} stuff won't work, but that's not
too hard to fix. You'll of course want to put the above in a shell script
and ignore it.)
Then instead of that ugly assignment in your .procmailrc, just say:
INCLUDERC = $HOME/.procmailrc.domains
Ta dah: perl doesn't have to run at all when a message comes it!
Philip Guenther