On Tue, Dec 26, 2000 at 11:38:49PM -0600, Bob Tanner wrote:
> Now, the hard part. Does anyone have time to perl program to search for all the
> mailto: links and change them to something like this?
> 
> before:
> 
> mailto:clueless at newbie.com
> 
> After:
> 
> mailto:clueless@newbie.com

Already done...  I created a little script (named doall.pl on my system) a
while ago for something or other similar.  If you can supply a sed expression
(call it $EXPR) which transforms the mailto:s, the syntax would simply be

doall.pl "sed -e $EXPR" *

to make the changes to all files in the current directory.  (For multiple
directories, `find . -exec doall.pl "sed -e $EXPR" {} \;` from the top of the
subtree you want to fix should do it.)

As for the value of $EXPR, here's a first approximation:

"s/mailto:\([^@]*\)@\([^ ]*\)/\mailto\:\1\@\2/ig"

It transforms the input addresses

mailto:clueless at newbie.com
mailto:Dave Sherohman <esper at sherohman.org>
mailto:tclug-list at lists.real-time.com

to the output

&#109;ailto&#58;clueless&#64;newbie.com
&#109;ailto&#58;Dave Sherohman <esper&#64;sherohman.org>
&#109;ailto&#58;tclug-list&#64;lists.real-time.com

It's not exactly what you asked for, but obfuscating the dots in addresses
(but not elsewhere) and the first letter of the TLD would require a
special-purpose script or a much more complex sed command.

Don't forget that you can also turn on some address obfuscation in Mailman,
but all it does is convert "esper at sherohman.org" to "esper at sherohman.org",
which isn't necessarily that effective.

Script follows.

--- Begin doall.pl ---

#!/usr/bin/perl -w
use strict;

my $cmd = shift;

while (my $filename = shift) {
  # Perform operation to new file.  Exit on error.
  if (`$cmd $filename 2>&1 >$filename.new`) { die };

  # If the output is different than the input, replace the old version with
  # the new one.  If nothing was changed, discared the new version and leave
  # the old one untouched.
  if (`diff $filename.new $filename`) {
    rename "$filename.new", $filename;
  } else {
    unlink "$filename.new";
  }
}

--- End doall.pl ---

-- 
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1:  GCS d? s+: a- C++ UL++$ P++>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r y+