Email-Address-Loose
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
inc/Email/Address.pm view on Meta::CPAN
}
sub __cache_parse {
return if $NOCACHE;
my ($class, $line, $addrs) = @_;
$PARSE_CACHE{$line} = $addrs;
}
sub parse {
my ($class, $line) = @_;
return unless $line;
$line =~ s/[ \t]+/ /g if $COLLAPSE_SPACES;
if (my @cached = $class->__get_cached_parse($line)) {
return @cached;
}
my (@mailboxes) = ($line =~ /$mailbox/go);
my @addrs;
foreach (@mailboxes) {
my $original = $_;
my @comments = /($comment)/go;
s/$comment//go if @comments;
my ($user, $host, $com);
($user, $host) = ($1, $2) if s/<($local_part)\@($domain)>//o;
if (! defined($user) || ! defined($host)) {
s/($local_part)\@($domain)//o;
($user, $host) = ($1, $2);
}
my ($phrase) = /($display_name)/o;
for ( $phrase, $host, $user, @comments ) {
next unless defined $_;
s/^\s+//;
s/\s+$//;
$_ = undef unless length $_;
}
my $new_comment = join q{ }, @comments;
push @addrs,
$class->new($phrase, "$user\@$host", $new_comment, $original);
$addrs[-1]->[_IN_CACHE] = [ \$line, $#addrs ]
}
$class->__cache_parse($line, \@addrs);
return @addrs;
}
#line 252
sub new {
my ($class, $phrase, $email, $comment, $orig) = @_;
$phrase =~ s/\A"(.+)"\z/$1/ if $phrase;
bless [ $phrase, $email, $comment, $orig ] => $class;
}
#line 274
sub purge_cache {
%NAME_CACHE = ();
%FORMAT_CACHE = ();
%PARSE_CACHE = ();
}
#line 290
sub disable_cache {
my ($class) = @_;
$class->purge_cache;
$NOCACHE = 1;
}
sub enable_cache {
$NOCACHE = undef;
}
#line 350
BEGIN {
my %_INDEX = (
phrase => _PHRASE,
address => _ADDRESS,
comment => _COMMENT,
original => _ORIGINAL,
);
for my $method (keys %_INDEX) {
no strict 'refs';
my $index = $_INDEX{ $method };
*$method = sub {
if ($_[1]) {
if ($_[0][_IN_CACHE]) {
my $replicant = bless [ @{$_[0]} ] => ref $_[0];
$PARSE_CACHE{ ${ $_[0][_IN_CACHE][0] } }[ $_[0][_IN_CACHE][1] ]
= $replicant;
$_[0][_IN_CACHE] = undef;
}
$_[0]->[ $index ] = $_[1];
} else {
$_[0]->[ $index ];
}
};
}
}
sub host { ($_[0]->[_ADDRESS] =~ /\@($domain)/o)[0] }
sub user { ($_[0]->[_ADDRESS] =~ /($local_part)\@/o)[0] }
#line 391
sub format {
local $^W = 0; ## no critic
return $FORMAT_CACHE{"@{$_[0]}"} if exists $FORMAT_CACHE{"@{$_[0]}"};
$FORMAT_CACHE{"@{$_[0]}"} = $_[0]->_format;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.042 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )