I like this construct better, though an if block is easier to read:
s/.* to=([^,]+), .*/$1/ && do { $to_addr = $_ };
If the substitution succeeds, $to_addr is set to the new value of $_.
Comment on (chromatic) Re: Strange Behavior while Parsing Sendmail logs
Out of curiosity, what does phrasing it in that way buy you?
I thought maybe you were gaining an advantage from the short circuit of && so I wrote a benchmark, but the times came back so close together that the difference is easily attributed to background processes. So I ran the deparser and found that perl converts this to an if(){} structure, which is (as you said) easier to read.
E:\Projects>perl -MO=Deparse -we "my $s; $_ && do { $s = $_ }"
my $s;
if ($_) {
$s = $_;
}
-e syntax OK