4 # Copyright (C) 2002-2003 Jan Kratochvil <project-PerlMail@jankratochvil.net>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 use vars qw($VERSION);
22 $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
27 require PerlMail::Contacts;
28 require Mail::Address;
31 Getopt::Long::Configure(
35 die if !Getopt::Long::GetOptions(
45 $record{$item{"FIELD"}}=$item{"FIELD-DATA"};
46 ($item{"FIELD"} ne "Mail" || !$item{"FIELD-DATA"} ? () : ({
47 "name"=>$record{"Name"},
48 "mail"=>$item{"FIELD-DATA"},
49 "attr"=>$item{"FIELD-NAME"},
50 "iscompany"=>($record{"Name"} && $record{"Company"} && $record{"Name"} eq $record{"Company"}),
53 } PerlMail::Contacts->import($_));
56 my($name,$mail,$attr,$iscompany)=map(($data->{$_}),qw(name mail attr iscompany));
60 while ($name=~s/"([^"]*)"([!])?//s) {
65 $name=~s/^(\w+)\s+(\w+)$/$2 $1/s if !$iscompany;
66 push @nicks,$name if !$name_force;
68 $_.=".$attr" if $attr;
73 "obj"=>Mail::Address->new(($name_force || $name),$mail),
77 print "alias ".$_->{"nick"}." ".$_->{"obj"}->format()."\n";