Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Efficient Way to Parse a Large Log File with a Large Regex

by Dru (Hermit)
on Apr 12, 2005 at 19:30 UTC ( #447148=note: print w/replies, xml ) Need Help??


in reply to Re: Efficient Way to Parse a Large Log File with a Large Regex
in thread Efficient Way to Parse a Large Log File with a Large Regex

Thanks. This is what I came up with based on your code:
use warnings; use strict; my @ips = qw/192.168.2.1 ..../; @ips = map { quotemeta } @ips; my $regex = join('|', @ips); my $re = qr[$regex]; while (<>) { print if /$re/; }
I'm then calling it liks so:
tail -f fw.log | /usr/local/scripts/parseips
It's taking up quite a bit of resources, but not bringing the server to it's knees.

Thank you for the other suggestions also. I'm going to come up with a more perm. solution based on one of these that does not require me to stare at a terminal.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://447148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-08-16 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (171 votes). Check out past polls.

    Notices?