Since we don't have the entire script I am taking a guess here.
I assume you are opening the log and reading through each line like so:
open FH, "mylog" etc....
do these steps
If you have the regex you listed in the "do these steps section"
then as it is written $to_addr will get assigned the entire line
because you have parenthesized that part and set the precedence for
the operations. You then run the regex
on the line but it never gets assigned to anything again. Try moving
the parens so it looks like this:
$to_addr = ($_ =~ rest of stuff);
Oops. Second code section is wrong as DrManhattan