The problem is that because you are using * everywhere, there are an exponential number of ways for that match to fail. Perhaps Perl is clever enough to avoid it, but it seems to me that if you hit a single malformed line, that expression could hang.
I'd recommend avoiding the issue by using + pretty much everywhere you have a *, and anchoring the ends with ^ and $. Also, as someone else mentioned, it would be better to get rid of all those printf's and replace them with:
print <<"END_FORMAT"; date time = $1 time taken = $2 c-ip = $3 . . . END_FORMAT
It also appears that you'd be better off doing a little extra work so that you can use split instead of a regex:
Alternatively, you could trymy ($user_agent) = /\"(.*)\"/; s/\".*\"//; my @F = split(/\s+/); print <<"END_FORMAT"; date time = $F[0] $F[1] time taken = $F[2] . . . cs(Content-Type) = $F[15] cs(User-Agent) = $user_agent sc-filter-result = $F[16] . . . END_FORMAT
(but remember to cut the parens off the relevant item.)my @F = /(\" .*? \" | \S+)/gx;
In reply to Re^3: fast greedy regex
by sfink
in thread fast greedy regex
by js1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |