MailTools
view release on metacpan or search on metacpan
t/extract.t view on Meta::CPAN
#
# Test the address/name extraction
#
require Mail::Address;
$/ = "";
chomp(@line = <DATA>);
print "1..",scalar(@line),"\n";
$i = 1;
foreach $ln (@line) {
next unless($ln =~ /\S/);
($test,$format,$name) = split /\n+/, $ln;
$q = (Mail::Address->parse($test))[0];
$ename = $q->name || "";
$eformat = $q->format || "";
$name = $ename unless defined $name;
if($ename eq $name && $eformat eq $format) {
print "ok ",$i,"\n";
}
else {
print "not ok ",$i,"\n";
print
print "# name '$name' != '$ename'\n" unless $ename eq $name;
print "# format '$format' != '$eformat'\n" unless $eformat eq $format;
}
$i++;
}
__DATA__
"Joe & J. Harvey" <ddd @Org>, JJV @ BBN
"Joe & J. Harvey" <ddd@Org>
Joe & J. Harvey
"Joe & J. Harvey" <ddd @Org>
"Joe & J. Harvey" <ddd@Org>
Joe & J. Harvey
JJV @ BBN
JJV@BBN
"spickett@tiac.net" <Sean.Pickett@zork.tiac.net>
"spickett@tiac.net" <Sean.Pickett@zork.tiac.net>
Spickett@Tiac.Net
rls@intgp8.ih.att.com (-Schieve,R.L.)
rls@intgp8.ih.att.com (-Schieve,R.L.)
R.L. -Schieve
bodg fred@tiuk.ti.com
bodg
m-sterni@mars.dsv.su.se
m-sterni@mars.dsv.su.se
jrh%cup.portal.com@portal.unix.portal.com
jrh%cup.portal.com@portal.unix.portal.com
Cup Portal Com
( run in 0.677 second using v1.01-cache-2.11-cpan-364913b4093 )