Might this work as well and be further simplified?
if (/From:/) {
m/^\w+:(\S+)$/ && push my @addr, Mail::Address->parse($1);
$address = $addr[0]->address;
$debug_text .= "Found $address at line $.\n";
}
two notes. first, I dont see mention of $string anywhere so I am assuming you meant $address.
second, im not sure why you needed to modify $_, when you could just stuff the match into $1, etc.
third, semantically I didnt see any reason to say "Found address" when its clear that's what this codelet is doing. :)
ymmv of course.
also, from perldoc perlop:
s/PATTERN/REPLACEMENT/egimosx
s Treat string as single line.
g Replace globally, i.e., all occurrences.
not quite sure why youre using either switch since youre matching a "From: foo@bar.com" not a "From: foo@bar.com baz bletch blah blah From: bar@brak.org".
sorry, this wasnt meant to be a round of perl golf, but there were a few simplifications i caught. :)
brother dep.
minor update:
would it be possible to just do this?
if (/^From:(\S+)$/) {
push my @addr, Mail::Address->parse($1);
$address = $addr[0]->address;
$debug_text .= "Found $address at line $.\n";
} else { next }
--
transcending "coolness" is what makes us cool. |