Hi All, I'm working on a bit of code to parse a logfile, grab the IP's and put them in the deny file. In the beginning of my code I'm grabbing all the IP's in the deny file, putting them in an array to check against later to make sure that IP is not already in the file. I can get all the information I need but when I do a comparison of the IP's grabbed from two files when there is a match is won't print the match!
Any help would be great! Thanks, Tim #!/usr/bin/perl -w #use strict; use IO::Handle; my $logfile = "/var/log/messages"; my $secv = "/var/log/secv"; my $hosts = "/etc/hosts.deny"; my $cody = "/etc/hosts.deny"; my @boxes; my $box; open(LOG, "$logfile") || die "Cannot open logfile for reading: $!"; open(SEC, ">$secv") || die "Can't open file!: $!"; open(HOST, "$hosts") || die "Can't open file!: $!"; #open(DEAD, ">$cody") || die "Can't open file!: $!"; foreach (<HOST>) { if($_ =~ /(\d+\.\d+\.\d+\.\d+)/) { push (@boxes, $_); } else { next; } } close HOST; while (<LOG>){ if($_ =~/Failed password for invalid/) { print SEC "Invalied user logon attempt!:$_\n"; if(/(\d+\.\d+\.\d+\.\d+)/) { $tim = $1; foreach $box (@boxes) { if($box =~ m/"$tim"/){ print "Match:$tim\n" } else { print "No Match:$box\n"; } } } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>