Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 13th, 2001, 05:07 AM
fighter fighter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: South Africa
Posts: 0 fighter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy

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

Reply With Quote
  #2  
Old April 13th, 2001, 09:51 AM
MrHyde MrHyde is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 15 MrHyde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > searching a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway