Owen wrote:
I have this regex to look at an Apache log.


There are modules to help with that task on CPAN.

m/^(\S+) \S+ \S+ \[(\d{2})\/(\S+)\/(\d{4}):.+\] "(\w+) (\S+)
([^"]+)" (\d{3}) (\d+|-) ".+"$/;

Would like to set it out in a bit more readable form a la Perl Cook Book and 
others

eg

m/
^(\S+)          # Comment
 \S+            # Comment
 \S+            # Comment

etc,

but "they don't work" and I suspect it is something to do with the spaces 
between the elements. I have even tried specifying spaces with \s


The key is to use the /x modifier on the end of the regex to allow this type of formatting. You then, according to perldoc perlretut, can either backslash "real" spaces or put them in a character class. See,

perldoc perlretut

for more.


Can someone give me a pointer as to how to go about this.

HTH,

http://danconia.org




TIA


Owen

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to