sample.pl untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 CC 2 SCAR 15.4
CC
2
Cov
0%
printif
6.0
BEGIN
2.0
CRAP 4.7
1 #!/usr/bin/perl
2 use BBDB;
3  
4  
5 ########################################################################
6 # Run through a bbdb file and collect all the unique names
7 # in the notes field and print them out seperated by spaces
8 ########################################################################
9 my %notes;
10 my $bbdb;
11 my $all = BBDB::simple("sample_data.bbdb");
12 foreach $bbdb (@$all) {
13 my $notes = $bbdb->part('notes');
14 next unless @$notes;
15 my @fields = map { $_->[0] } @$notes;
16 @notes{@fields} = 1;
17 }
18 print join(' ',keys %notes),"\n\n";
19  
20 ########################################################################
21 # Run through the bbdb file and print out everybody that has
22 # a mailing address in a "standard" mailing label like format
23 ########################################################################
24 sub printif {
25 my $s = shift;
26 print "$s\n" if $s;
27 }
28  
29 foreach $bbdb (@$all) {
30 my $i;
31 for ($i=0; $i < @{$bbdb->part('address')}; $i++) {
32 my $address = $bbdb->part('address')->[$i];
33 if ($address->[0] eq 'mailing' ) {
34 printf "%s %s\n",$bbdb->part('first'),$bbdb->part('last');
35 map { printif $_ } @{$address->[1]};
36 printf "%s, %s, %s\n%s\n",@$address[2..5];
37 }
38 }
39 }
40 ########################################################################