Owen wrote: > I have this regex to look at an Apache log. > > 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 > > Can someone give me a pointer as to how to go about this.
$ perl -le' print $1 if "one two three four" =~ / ^ # start of line ( \S+ # capture one or more non-whitespace ) \ # a single space character \S+ # match one or more non-whitespace [ ] # a single space character \S+ # match one or more non-whitespace \ # a single space character /x ' one John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/