+++ /dev/null
-#! /usr/bin/perl
-#
-# $Id$
-# Copyright (C) 2002-2003 Jan Kratochvil <project-PerlMail@jankratochvil.net>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# Name: Lastname Firstname "nick1" "nick2", dropped text
-# Company: same as Name to indicate company record
-
-
-use vars qw($VERSION);
-$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
-use strict;
-use warnings;
-
-require Getopt::Long;
-require Mail::Address;
-
-
-Getopt::Long::Configure(
- "no_ignorecase",
- "bundling",
- );
-my $opt_9000;
-die if !Getopt::Long::GetOptions(
- "9000"=>\$opt_9000,
- );
-
-my $type="9210";
-$type="9000" if $opt_9000;
-my $class="PerlMail::Contacts::$type";
-eval "require $class;1;" or die "Cannot load loader $class: $!";
-
-undef $/;
-while (<>) {
- my @data=map({
- my @record=@$_;
- my %record;
- map({
- my %item=%$_;
- $record{$item{"FIELD"}}=$item{"FIELD-DATA"};
- ($item{"FIELD"} ne "Mail" || !$item{"FIELD-DATA"} ? () : ({
- "name"=>$record{"Name"},
- "mail"=>$item{"FIELD-DATA"},
- "attr"=>$item{"FIELD-NAME"},
- "iscompany"=>($record{"Name"} && $record{"Company"} && $record{"Name"} eq $record{"Company"}),
- }));
- } @record);
- } $class->in($_));
- my @nicked=map({
- my $data=$_;
- my($name,$mail,$attr,$iscompany)=map(($data->{$_}),qw(name mail attr iscompany));
- $name=~s/,.*$//s;
- my @nicks=();
- my $name_force;
- while ($name=~s/"([^"]*)"([!])?//s) {
- push @nicks,$1;
- $name_force=$1 if $2;
- }
- $name=~s/\s*$//s;
- $name=~s/^(\w+)\s+(\w+)$/$2 $1/s if !$iscompany;
- push @nicks,$name if !$name_force;
- for (@nicks) {
- $_.=".$attr" if $attr;
- s/\s+/./gs;
- }
- map({
- "nick"=>$_,
- "obj"=>Mail::Address->new(($name_force || $name),$mail),
- },@nicks);
- } @data);
- my %dupe;
- for (@nicked) {
- my $nick=$_->{"nick"};
- my $dupe=$dupe{$nick}++;
- $nick.=".$dupe" if $dupe;
- print "alias $nick ".$_->{"obj"}->format()."\n";
- }
- }