in reply to Acolyte needs regex help
From what I see at first glance, you seem to be missing a + on the last (\S) sequence.
I always debug my REs by deleting enough stuff such that it matches again. Then I add step by step the other stuff back in.
In your case, you might want to rewrite the code such that it logs "bad" lines into a separate file (untested code !):
Update :Shendal noted below that I didn't fix the problem with the RE, and that's correct. I have now modified the RE so that it should match :)
#!/usr/bin/perl -w use strict; my $filename = "access.log"; my ($client,$identuser,$authuser,$date,$tz,$method,$url,$protocol,$sta +tus,$bytes,$refer,$platform,$extendedinfo) open( FILE, "< $filename" ) or die ("Couldn't open $filename : !$\n" ) +; while (<FILE>) { if ( /^(\S+) (\S+) (\S+) \[(\S+) (\S+)\] "(\S+) (\S+) (\S+)" (\S+) ( +\S+) "(\S+)" "(\S+) (.*?)"$/ ) { ($client,$identuser,$authuser,$date,$tz,$method,$url,$protocol,$st +atus,$bytes,$refer,$platform,$extendedinfo) = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13); } else { print "Unmatched log entry : $_"; }; }; close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Acolyte needs regex help
by Shendal (Hermit) on Jun 23, 2000 at 18:35 UTC | |
|
RE: Re: Acolyte needs regex help
by Dungan (Initiate) on Jun 24, 2000 at 05:42 UTC | |
|
RE: Re: Acolyte needs regex help
by Dungan (Initiate) on Jun 24, 2000 at 05:44 UTC | |
|
RE: Re: Acolyte needs regex help
by Dungan (Initiate) on Jun 24, 2000 at 05:46 UTC | |
|
RE: Re: Acolyte needs regex help
by Dungan (Initiate) on Jun 24, 2000 at 05:47 UTC | |
|
RE: Re: Acolyte needs regex help
by Dungan (Initiate) on Jun 24, 2000 at 05:49 UTC |