|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have written a perl program to examine a log file...
The line that i think is causing the trouble is: $regEx = "\w+ - - \[[\w\s]*\ $docRegEx"; (if statements to check whether that line is in the file) The above line is supposed to match the document requested in the logfile. For example a line of the logfile might look like this: quark - - [24/Oct/1999:04:40:10 +0600] "GET /images/black/off.GIF HTTP/1.0" 404 - And if $docRegEx was set to /images/black/off.GIF it should match it. The problem is it doesn't. Any idea whats wrong with it? thanks in advance, Nick |
|
#2
|
|||
|
|||
|
Try this out:
#!/usr/bin/perl $docRegEx = '/images/black/off.GIF'; $line = 'quark - - [24/Oct/1999:04:40:10 +0600] "GET /images/black/off.GIF HTTP/1.0" 404 - '; if ($line =~ /^[\w -]+\[[^\]]+\] "\w+ $docRegEx/) { print "Match!\n"; } else { print "No Match!\n"; } exit; It looks like the ending bracket was missing (the one after the number 600). |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > searching a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|