blib/lib/Email/IsFree/CN.pm

filter: Statementstmt 47.8% 11 / 23 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 3 totaltotal 38.8% 14 / 36 CC 3 SCAR 12.9
CC
3
Cov
41%
new
6.0
by_domain
6.0
by_email
2.0
CRAP 3.6
↑ Summary
1 package Email::IsFree::CN;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 $VERSION = '0.01';
9  
10 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
11 0 my $class = shift;
12 0 my %domains;
13  
14 0 ▶ while (<DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline DATA)) 0 0 0
15 0 chomp;
16 0 $domains{$_} = 1;
17 }
18  
19 0 bless { domains => \%domains },$class;
20 }
21  
22 0 ▶sub by_domain {
Subroutine by_domain: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my $self = shift;
24 0 my $domain = lc(+shift);
25 0 ▶ return exists $self->{domains}->{$domain} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'domains'}{$domain} ? : 0 0 0
26 }
27  
28 0 ▶sub by_email {
Subroutine by_email: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my $self = shift;
30 0 my $email = shift;
31 0 return $self->by_domain((split('@',$email))[-1]);
32 }
33  
34 2 1;
35  
36 =pod
37  
38 =head1 NAME
39  
40 Email::IsFree::CN - Detect whether e-mail is from free provider in China
41  
42 =head1 SYNOPSIS
43  
44 use Email::IsFree::CN;
45  
46 my $cnfm = Email::IsFree::CN->new;
47 print $cnfm->by_domain('163.com'); # print 1
48 print $cnfm->by_email('foo@sina.com'); # print 1
49 print $cnfm->by_email('bar@vip.163.com'); # print 0
50  
51 =head1 ABSTRACT
52  
53 This module detects whether an e-mail address belongs to a
54 free e-mail provider in China such as 163.com or sina.com.
55  
56 =head1 DESCRIPTION
57  
58 This module can be used to screen credit card orders based
59 on e-mail. Many credit card scamsters use free, anonymous
60 email accounts with another person's name to place fraudulent
61 orders.
62  
63 =head1 AUTHOR
64  
65 Xiaolan Fu <GZ_AF@yahoo.com>
66  
67 =head1 CREDITS
68  
69 I got the idea from the module Email::IsFree whose author is
70 TJ Mather, thanks.
71  
72 =head1 COPYRIGHT AND LICENSE
73  
74 Copyright 2009 by Xiaolan Fu
75  
76 This library is free software; you can redistribute it and/or modify
77 it under the same terms as Perl itself.
78  
79 =cut
80  
81 __DATA__
↑ Summary