I get the phone numbers of incoming calls via ISDN.  And i want
to have a Message printed on my screen with the real name stored in my 
BBDB.  Something like jwz's cid.

Until now, i used Seth's bbdb.pl with minor modifications.  But what i
really want is a list, with every known number in one line, which i
can grep *fast*.

I'll dump it on the list, perhaps later i'll put it on a Webpage.
Waider?


Aldo

#!/usr/bin/perl
#
# Aldo Valente, [EMAIL PROTECTED], Sat Feb 24 08:30:29 CET 2001
# 
# bbdb2phone.  reads a ~/.bbdb and prints a list of normalized
# phonenumbers, each *phonenumber* with all names on one line.
# 
# I use the resulting list for identification of incoming call.
#
# $Id: bbdb2phone,v 1.1 2001/02/24 11:31:15 aldo Exp aldo $
#
# $Log: bbdb2phone,v $
# Revision 1.1  2001/02/24 11:31:15  aldo
# Initial revision
#

use Lisp::Reader ;

$cc='0049'; # Cc
$ci='228';  # City

sub norm{
  # input is something like '+49-(228)-123/45 67'
  # returns '00492281234567'
  my $a = undef;
  $a = $_[0];
  $a =~ s/^\+/00/;  # fuehrendes `+' zu `00'
  $a =~ s/[^0-9]//g; # junk
  $a =~ s/^([1-9])/$cc$ci$1/; # add City
  $a =~ s/^0([1-9])/$cc$1/;    # add CC
# Now it's  00492281234567, but *I* need to remove cc
#  $a =~ s/^0049/0/;  #  Bzzzt, don't ask.
#  $a =  '**81' . $a;  # 
  return $a;
}

RECORD:
while (<>) {
  $name = $phone  = $loc = undef;
  @BBDB = @{${&Lisp::Reader::lisp_read($_)}[0]};
  # below is        name  lname  aka          title
  $name = join ' ', @BBDB[0..1], $BBDB[2][0], $BBDB[3];
  next RECORD if "$name" eq '   ';
  while ($phone = shift @{$BBDB[4]}) {
    $loc = shift @{$phone};
    $phone = join ' ', @{$phone};
    $phone = norm($phone);
    $phone{$phone} .= ": $loc: $name";
  }
}                                             
foreach $i (keys %phone) {
  print "$i\t$phone{$i}\n";
}


_______________________________________________
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to