Subject: Conversion of elm aliases to pine addressbook

From: @kant.Physik.Uni-Dortmund.DE (Klaus Wacker)
Date: 9 Nov 1994 13:34:40 GMT

Does anybody have a filter which converts elm's aliases.text to pine
addressbook format? I guess it is pretty straight forward to do, but
it would save me some work if its been done already.

Is it right that there can be only one nickname per addressbook entry?
Elm allows several.

Finally, is there a FAQ for comp.mail.pine?

--
 
|  / |              | | |        |            [email-masked]
| /  |  _       __  | | |  _   _ |     _   _  Klaus Wacker, Exp.Physik V
|/\  |  _\ | | (_   | | |  _\ /  |_)  /_) |   Uni Dortmund
|  \_|_(_|_|_|___)  |_|_|_(_|_\__| \_/\___|   D-44221 Dortmund 
                                              +49 (231) 755 3587

---

From: [email-masked] (Klaus Wacker)
Date: 13 Nov 1994 16:47:42 GMT

Following up on my own request...

> it would save me some work if its been done already.

I received one script by email, which seems to work only in simple
cases, and I found something in the FAQ, where however the most
important part is missing. Meanwhile, I wrote my own perl script,
which I claim digests everything elm accepts and converts it into
something pine accepts. Please tell me if you find otherwise. I intend
to use this script regularly to keep system-wide aliases and
addressbooks in synch. It is appended below.

> Is it right that there can be only one nickname per addressbook entry?

Since I haven't heard anything to the contrary, the script below
assumes this.

> Finally, is there a FAQ for comp.mail.pine?

I saw one in the meantime, but I still ask myself why it can't be
found in the usual places.

Finally, I want to apologize for the mangled From-headers of my
previous postings. It was due to a combination of a tin "feature" and
the way I used xterm, and I hope it is corrected with this posting.

--

----------------------cut-here----------------------------------------
#!/usr/local/bin/perl
# 
# elm-to-pine: Convert elm aliases file to pine address book
# Author: Klaus Wacker ([email-masked])
#
# Usage e.g.
# elm-to-pine ~/.elm/aliases.text >~/.addressbook
#

# get a line, combining continuation lines
#  that start with whitespace
# (taken from the perl man page and modified)
sub get_line {
    return 0 if eof();
    $thisline = $lookahead;
  line: while ($lookahead = <>) {
      if ($lookahead =~ /^[ \t]/) {
	  $thisline .= $lookahead;
      }
      else {
	  last line;
      }
  }
    $thisline;
}

$lookahead = <>;	# get first line
while ($_ = do get_line()) {
    next if /^\#/;		# Skip comments
    chop;
    s/\t/ /g;			# Lets not get confused by any tabs in the file
    ($nicks,$name,$address)=split(/ *= */,$_,3);
    @nick=split(/ *, */,$nicks);
    ($fullname,$remark)=split(/ *, */,$name,2);
    $fullname =~ s/;/,/;	# Lastname[;,] Firstname
    if ($address =~ /,/ ) {$address="(".$address.")";} # Its a list
    foreach $nicki (@nick) {	# Pine doesn't allow multiple nicknames
	printf "%s\t%s\t%s\t\t%s\n",
	$nicki, $fullname, $address, $remark;
	$address = $nick[0];	# Let additional nicks point to the first one
    }
}
----------------------cut-here----------------------------------------