Simple, parse the dates and octets from the hacklist. Currently I get this:### Haxor ### #!/usr/bin/perl -w use strict; use warnings; my $flag = 0; my $hacklist = "hack.txt"; my $date = 'Date: '; my $octet = '(\d{1,3}\.){3}\d{1,3}'; open HACK, $hacklist or die "Can't Open $hacklist"; my @hack=<HACK>; close(HACK); foreach (@hack) { if (s/$date//){ print; $flag = 0; } if (/$octet/ and !$flag){ print STDOUT $_; print "\n"; $flag = 1; } }
But how do I print only the octet? Everything else on that line is unecessary. Is there a way to print only the matched pattern, disregarding everything else on the line? Ideal results would be:Thursday, December 13, 2001 07:53 AM Subject: FW: Please disconnect 208.202.183.42 thanks. Monday, December 17, 2001 08:56 AM Subject: FW: Please disconnect 213.14.199.133 thanks.
Hopefully I will get 'Mastering Regular Expressions' for Christmas. Happy Holidays!Thursday, December 13, 2001 07:53 AM 208.202.183.42 Monday, December 17, 2001 08:56 AM 213.14.199.133
In reply to Octet Regex by amearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |