
asandybox
Novice
Jun 19, 2012, 2:47 PM
Post #12 of 14
(7626 views)
|
|
Re: [asandybox] Stuck on how to iterate a list in a file against a logfile.
[In reply to]
|
Can't Post
|
|
Guys, After some head banging, hair pulling, I think I have a workable solution: I went back to the drawing board with the hint that "rovf" provided and came up with the following:
#!/usr/bin/perl use warnings; use strict; my $file = "ip.txt"; open (FH, "< $file") or die "Can't open $file for read: $!"; my @lines=<FH>; chomp @lines; my $regexstring = join("|",@lines); #print "($regexstring)"; while (<>) { my $line = $_; if ($line =~ /($regexstring)/i) { print; } } close FH or die "Cannot close $file: $!"; Appears to do the job. Don't think it's very efficient, but it works for the task at hand and I can start to munge our proxy logs for some needed information. Thank you FishMonger and Rovf for your inputs. Very helpful for me to finally figuring things out.
(This post was edited by asandybox on Jun 19, 2012, 2:48 PM)
|