Hi!

"m{ pattern }" is regular expression to parse log string.

It's equal to just "/ pattern /". Using different delimiter is convenient here because usually symbol "/" must be escaped with backslash "\", but if we use another delimiter - we can left "/" symbol unescaped and reges is more readable.

You can further explore regex with this site https://regex101.com/r/4CGCcB/2


On 7/12/18 2:35 PM, Lauren C. wrote:
Hello,

My web is powered by Apache and PHP,its access log seems as blow,

xx.xx.xx.xx - - [12/Jul/2018:19:29:43 +0800] "GET /2018/07/06/antique-internet/ HTTP/1.1" 200 5489 "https://miscnote.net/"; "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"

A perl script for stat purpose of this log:

tail -f /var/log/apache2/access.log|perl -nle 'next unless m{^(\S+) - - \[(\S+).*\] \"GET (.*?/)\s+}; printf "%-20s%-40s%-40s\n",$1,$3,$2'

I was totally confused about it.
 what does m{...} and its content stand for?
Can you help give a explain?

thanks in advance.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to