- It would seem that somehow the whole log line is getting matched by the (^,+) part of the regex because that's what's getting substituted back in.
Just in case this isn't clear yet, it isn't that the mentioned part of the regex is matching the whole line, it is that the regex is failing and no substitution is taking place
It does no good to have an unanchored .* at both ends.
This looks like one of the regex optimizer bugs. You should post it to comp.lang.perl.moderated or submit it with perlbug.
I'd write this:
if( $_ =~ / to=([^,]+), / ) {
$to_addr = $1;
} else {
warn "Unmatched to= in line: $_";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.