File Coverage

blib/lib/Email/Find/addrspec.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Email::Find::addrspec;
2              
3 4     4   21383 use strict;
  4         8  
  4         145  
4 4     4   19 use vars qw($VERSION @EXPORT $Addr_spec_re);
  4         7  
  4         264  
5             $VERSION = 0.09;
6              
7 4     4   18 use base qw(Exporter);
  4         10  
  4         1509  
8             @EXPORT = qw($Addr_spec_re);
9              
10             # This is the BNF from RFC 822
11             my $esc = '\\\\';
12             my $period = '\.';
13             my $space = '\040';
14             my $open_br = '\[';
15             my $close_br = '\]';
16             my $nonASCII = '\x80-\xff';
17             my $ctrl = '\000-\037';
18             my $cr_list = '\n\015';
19             my $qtext = qq/[^$esc$nonASCII$cr_list\"]/; #"
20             my $dtext = qq/[^$esc$nonASCII$cr_list$open_br$close_br]/;
21             my $quoted_pair = qq<$esc>.qq<[^$nonASCII]>;
22             my $atom_char = qq/[^($space)<>\@,;:\".$esc$open_br$close_br$ctrl$nonASCII]/; #"
23             my $atom = qq<$atom_char+(?!$atom_char)>;
24             my $quoted_str = qq<\"$qtext*(?:$quoted_pair$qtext*)*\">; #"
25             my $word = qq<(?:$atom|$quoted_str)>;
26             my $local_part = qq<$word(?:$period$word)*>;
27              
28             # This is a combination of the domain name BNF from RFC 1035 plus the
29             # domain literal definition from RFC 822, but allowing domains starting
30             # with numbers.
31             my $label = q/[A-Za-z\d](?:[A-Za-z\d-]*[A-Za-z\d])?/;
32             my $domain_ref = qq<$label(?:$period$label)*>;
33             my $domain_lit = qq<$open_br(?:$dtext|$quoted_pair)*$close_br>;
34             my $domain = qq<(?:$domain_ref|$domain_lit)>;
35              
36             # Finally, the address-spec regex (more or less)
37             $Addr_spec_re = qr<$local_part\s*\@\s*$domain>;
38              
39             1;
40             __END__