in reply to regexp matching bad stuff ...

Earlier I recommended

perl -ne'if (s/.../.../) { print } else { print STDERR }' <access_log 2>out.err >out.csv

What I had in mind was

perl -ne'print { s/.../.../ ? STDOUT : STDERR } $_' <access_log 2>out.err >out.csv

It just occured to me that it can be shortened to

perl -pe'select s/.../.../ ? STDOUT : STDERR' <access_log 2>out.err >out.csv