/usr/bin/bbdb-areacode-split is in bbdb 2.36-4.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/usr/bin/perl
#
# Looks for phone numbers in your .bbdb with a particular area code
# and one of a set of exchanges and changes the area code. The old
# and new area codes are specified on the command line, as is the
# location of a file that contains the exchanges that are being
# changed. (The format of that file is very loose. Every three digit
# sequence will be used.)
#
# Seth Golub <seth@cs.wustl.edu>
# 15 Aug 1997
sub Usage
{
$0 =~ s@.*/@@;
die "Usage: \n $0 <old-code> <new-code> <exchanges-file> [bbdb]\n";
}
$old_area_code = shift || Usage();
$new_area_code = shift || Usage();
$exchange_list_file = shift || Usage();
$bbdb_file = $ENV{'BBDB'} || shift || $ENV{'HOME'} . '/.bbdb';
$bbdb_dir = `dirname $bbdb_file`; chomp $bbdb_dir;
$tmp_file = "$bbdb_dir/bbdb.new-$$";
open( LIST, "<$exchange_list_file" )
|| die "Failed to open $exchange_list_file\n";
while (<LIST>)
{
while ( /(\d\d\d)/g )
{
push( @exchanges, $1 );
}
}
close( LIST );
$exchanges = join( '|', @exchanges );
open( BBDB_IN, "<$bbdb_file" ) || die "Failed to open $bbdb_file\n";
open( BBDB_OUT, ">$tmp_file" ) || die "Failed to open $tmp_file\n";
while (<BBDB_IN>)
{
next unless /^\[/;
s/(\[\".*?\") $old_area_code (($exchanges) \d+ \d+\])/$1 $new_area_code $2/og;
} continue {
print BBDB_OUT;
}
close( BBDB_IN );
close( BBDB_OUT );
unlink( "$bbdb_file.bak" );
rename( $bbdb_file, "$bbdb_file.bak" );
rename( $tmp_file, $bbdb_file );
print STDERR "Old bbdb moved to $bbdb_file.bak\n";
__END__
|