|Perl: the Markov chain saw|
Strange Behavior while Parsing Sendmail logsby Russ (Deacon)
|on Jul 19, 2000 at 01:03 UTC||Need Help??|
Russ has asked for the wisdom of the Perl Monks concerning the following question:
Jul 17 10:26:30 email@example.com sendmail:
This log line (and others like it, all have double quotes in the email address), does not behave as i think it should. $_ contains the log line when i execute the following statement:
However, $to_addr does not end up containing the data following the 'to=' delimiter, it ends up containing the whole log line. 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.
What's even stranger is if i simulate this situation in the debugger (by entering the log line into a variable and performing the same substition) it works exactly as expected.
The log line has been altered for obvious reasons. It is of course on a single line in its original form.
And yes, I know you can't technically write a regex to match an email address, but this *should* be close enough.