| 1 | package BBDB::Export::MailAliases; | ||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.015'; | |||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 1 | our @ISA = qw(BBDB::Export); | |||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||
| 13 | #_* process_record | ||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | sub process_record | ||||||||||||||||||||||
| 17 | 7 | ▶ | { | ||||||||||||||||||||
|
Subroutine
process_record: called CC=9 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||
| 18 | 7 | my ( $self, $record ) = @_; | |||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 7 | ▶ | return unless ( $record ); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 21 | 7 | ▶ | return unless ( $record->{'full'} ); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 22 | 7 | ▶ | return unless ( $record->{'net'} ); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 2 | my $email = $record->{'net'}->[0]; | |||||||||||||||||||||
| 25 | 2 | my $full = $record->{'full'}; | |||||||||||||||||||||
| 26 | |||||||||||||||||||||||
| 27 | # determine nick | ||||||||||||||||||||||
| 28 | 2 | my $nick; | |||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 2 | ▶ | if ( $record->{'nick'} ) | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||
| 32 | # use the first nick in the list | ||||||||||||||||||||||
| 33 | 0 | $nick = ( split( /,/, $record->{'nick'} ) )[0]; | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||
| 35 | ▶ | elsif ( $record->{'first'} && $record->{'last'} ) | |||||||||||||||||||||
|
Condition33%1/3
$record->{"first"} and $record->{"last"}
MC/DC0%0/2
$record->{"first"} and $record->{"last"}
$record->{"first"}
$record->{"last"}
Truth table33%1/3
A and B
A= $record->{"first"}B= $record->{"last"}
| |||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||
| 37 | # build nick of first name and first char of last name | ||||||||||||||||||||||
| 38 | 2 | $nick = $record->{'first'}; | |||||||||||||||||||||
| 39 | 2 | $nick =~ s|\s.*$||; | |||||||||||||||||||||
| 40 | 2 | $nick .= substr( $record->{'last'}, 0, 1 ); | |||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||
| 42 | elsif ( $record->{'last'} ) | ||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||
| 44 | # use last name for nick | ||||||||||||||||||||||
| 45 | 0 | $nick = $record->{'last'} | |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | elsif ( $record->{'first'} ) | ||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||
| 49 | # use first name for nick | ||||||||||||||||||||||
| 50 | 0 | $nick = $record->{'first'}; | |||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | # acceptable characters | ||||||||||||||||||||||
| 54 | 2 | $nick =~ tr/a-zA-Z//cd; | |||||||||||||||||||||
| 55 | |||||||||||||||||||||||
| 56 | # lower case the nick | ||||||||||||||||||||||
| 57 | 2 | $nick = lc( $nick ); | |||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 2 | return qq(alias $nick "$full" <$email>\n); | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||
| 61 | |||||||||||||||||||||||
| 62 | # | ||||||||||||||||||||||
| 63 | #_* post_processing | ||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||
| 65 | |||||||||||||||||||||||
| 66 | sub post_processing | ||||||||||||||||||||||
| 67 | 7 | ▶ | { | ||||||||||||||||||||
|
Subroutine
post_processing: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 68 | 7 | my ( $self, $output ) = @_; | |||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 7 | ▶ | return unless $output; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 71 | |||||||||||||||||||||||
| 72 | 2 | my $outfile = $self->{'data'}->{'output_file'}; | |||||||||||||||||||||
| 73 | 2 | ▶ | return unless $outfile; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | 0 | ▶ | open ( my $out_fh, ">", $outfile ) or die "Unable to create $outfile"; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 76 | 0 | print $out_fh $output; | |||||||||||||||||||||
| 77 | 0 | close $out_fh; | |||||||||||||||||||||
| 78 | |||||||||||||||||||||||
| 79 | 0 | $self->info( "Exported mail_aliases data to $outfile" ); | |||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||
| 81 | |||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | |||||||||||||||||||||||