Subject: | Eliminate warnings when running "make test" |
Eliminate warnings when running tests.
Also available on github:
http://github.com/mstevens/mail-deliverystatus-bounceparser/commit/a16ff151e9fb6bb3930c884678efee6dfa07d74a
and pull request sent to rjbs.
commit a16ff151e9fb6bb3930c884678efee6dfa07d74a
Author: Michael Stevens <mstevens@etla.org>
Date: Fri Nov 13 15:55:01 2009 +0000
Eliminate warnings in Mail::Header that were showing when "make test"
was run.
diff --git a/lib/Mail/DeliveryStatus/BounceParser.pm
b/lib/Mail/DeliveryStatus/BounceParser.pm
index a288d42..760a9d6 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -381,7 +381,10 @@ sub parse {
}
for my $hdr (qw(Reporting-MTA Arrival-Date)) {
- $report->replace($hdr => $global{$hdr} ||= $report->get($hdr))
+ my $val = $global{$hdr} ||= $report->get($hdr);
+ if (defined($val)) {
+ $report->replace($hdr => $val)
+ }
}
my $email;
@@ -434,13 +437,15 @@ sub parse {
my ($code) = $report->get('diagnostic-code') =~
m/ ( ( [245] \d{2} ) \s | \s ( [245] \d{2} ) (?!\.) ) /x;
- $report->replace(smtp_code => $code);
+ if ($code) {
+ $report->replace(smtp_code => $code);
+ }
if (not $report->get("host")) {
$report->replace(host => ($report->get("email") =~ /\@(.+)/)[0])
}
- if ($report->get("smtp_code") =~ /^2../) {
+ if ($report->get("smtp_code") and ($report->get("smtp_code") =~
/^2../)) {
$self->log(
"smtp code is "
. $report->get("smtp_code")