Convert/PersistentUtilities.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 34 / 34 CC 3 SCAR 6.2
CC
3
Cov
100%
makeAliasUnique
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Convert/Spry.pm ↑ Summary Convert/Mailrc.pm »
1 =head1 NAME
2  
3 Mail::Addressbook::Convert::PersistentUtilities
4  
5 =head1 SYNOPSIS
6  
7 This module is not designed to be used by the user.
8  
9 It provides a method with values that persist between calls.
10  
11 =head1 REQUIRES
12  
13 Perl, version 5.001 or higher
14  
15 Carp
16  
17 =head1 DESCRIPTION
18  
19  
20 =head1 DEFINITIONS
21
22
23  
24 =head1 METHODS
25  
26 =head2 new
27  
28 no arguments needed.
29  
30 =head2 makeAliasUnique
31  
32 Input
33  
34 Parameter 1 : A email alias ( string )
35 Parameter 2 boolean. if true underscores are allowed in aliases
36 if false, they are eliminated
37
38 Returns
39  
40 An alias, which is unique among all the previous aliases called during the life of
41 the object.
42  
43  
44  
45  
46 =head1 LIMITATIONS
47  
48  
49  
50 =head1 REFERENCES
51  
52
53  
54 =head1 HISTORY
55  
56 This code is derived from the code used on www.interguru.com/mailconv.htm . The site
57 has been up since 1996 ( but ldif was only included on 1997, when Netscape 3 started
58 using it.) The site gets about 8000 unique visitors a month, many of whom make addressbook
59 conversions. The code has been well tested.
60  
61 =head1 FUTURE DIRECTIONS
62  
63  
64  
65  
66 =head1 BUGS
67  
68 =head1 CHANGES
69  
70 Original Version 2001-Sept-09
71
72 =head1 COPYRIGHT
73  
74 Copyright (c) 2001 Joe Davidson. All rights reserved.
75 This program is free software; you can redistribute it
76 and/or modify it under the terms of the Perl Artistic License
77 (see http://www.perl.com/perl/misc/Artistic.html). or the
78 GPL copyleft license ( http://www.gnu.org/copyleft/gpl.html)
79  
80  
81 =head1 AUTHOR
82  
83 Mail::Addressbook::Convert was written by Joe Davidson <jdavidson@interguru.com> in 2001.
84  
85 =cut
86  
87  
88  
89 package Mail::Addressbook::Convert::PersistentUtilities;
90  
91 # This class contain methods which need persistent values.
92  
93 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 1 ▶use Mail::Addressbook::Convert::Utilities;
Subroutine BEGIN: called CC=1 SCAR=0.0
95  
96 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
97  
98 ############################
99  
100 sub new
101 10 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
102 10 my $self=shift;
103 10 my %usedAlias;
104 10 return bless
105 { ADDNUM=> 100,
106 USEDALIAS =>\%usedAlias
107 }, $self;
108 }
109  
110  
111 ##########################################################################3
112 sub makeAliasUnique
113 73 ▶ {
Subroutine makeAliasUnique: called CC=3 SCAR=11.0
Pod documented
114
115
116 73 my ($self,$inputAlias,$allowUnderscores) = @_;
117
118 73 my $alias = &cleanalias($inputAlias,$allowUnderscores);
119 73 ▶ if (substr ($alias, -1,1) =~ /\d/) # does alias end in a number
Branch: 1 branch
BranchTrueFalseTotal
if (substr($alias, -1, 1) =~ /\d/) 12 61 73
120 {
121 12 $alias = $alias."a";
122 }
123 73 ▶ if ($self->{USEDALIAS}{$alias})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"USEDALIAS"}{$alias}) 7 66 73
124 {
125 7 my $addNum = $self->{ADDNUM};
126 7 $alias = $alias.$addNum;
127 7 $self->{ADDNUM}++;
128 }
129 73 $self->{USEDALIAS}{$alias} = 1;
130 73 return $alias;
131 }
132  
133 ##########################################################################3
134  
135 1 return 1;
« Convert/Spry.pm ↑ Summary Convert/Mailrc.pm »