X-Git-Url: http://git.jankratochvil.net/?p=PerlMail.git;a=blobdiff_plain;f=contacts-n9k2mutt;h=6136f45b5dafb0bde280ffd06fcdbb97aeda01c9;hp=fb3ef2168db532d7d2e3255d9bba5e96147cbcbc;hb=0dd6e159920b9402e163cd35bdc8465dcfee65c9;hpb=27215e02d26593b42ed643066f0659d8f24547b7 diff --git a/contacts-n9k2mutt b/contacts-n9k2mutt index fb3ef21..6136f45 100755 --- a/contacts-n9k2mutt +++ b/contacts-n9k2mutt @@ -1,6 +1,25 @@ #! /usr/bin/perl -# -# $Id$ +# +# $Id$ +# Copyright (C) 2002-2003 Jan Kratochvil +# +# 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; }; @@ -8,7 +27,6 @@ use strict; use warnings; require Getopt::Long; -require PrecislovaniLace::Contacts; require Mail::Address; @@ -16,9 +34,16 @@ 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({ @@ -34,7 +59,7 @@ while (<>) { "iscompany"=>($record{"Name"} && $record{"Company"} && $record{"Name"} eq $record{"Company"}), })); } @record); - } PrecislovaniLace::Contacts->import($_)); + } $class->in($_)); my @nicked=map({ my $data=$_; my($name,$mail,$attr,$iscompany)=map(($data->{$_}),qw(name mail attr iscompany)); @@ -57,7 +82,11 @@ while (<>) { "obj"=>Mail::Address->new(($name_force || $name),$mail), },@nicks); } @data); + my %dupe; for (@nicked) { - print "alias ".$_->{"nick"}." ".$_->{"obj"}->format()."\n"; + my $nick=$_->{"nick"}; + my $dupe=$dupe{$nick}++; + $nick.=".$dupe" if $dupe; + print "alias $nick ".$_->{"obj"}->format()."\n"; } }