Changeset 127 in lab


Ignore:
Timestamp:
Oct 29, 2011 7:36:14 PM (9 years ago)
Author:
mitty
Message:
  • get ip address lists from apache.log
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/misc/addr.pl

    r126 r127  
    44use warnings; 
    55 
    6 my $domain = '\@(([-a-z0-9]+\.)*[a-z]+)'; 
     6my $ip = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'; 
    77 
    88my $file = shift @ARGV; 
    99open FILE, $file; 
    1010 
    11 my $domains = {}; 
     11my $addr = {}; 
    1212while (my $line = <FILE>) { 
    13     if ($line =~ /$domain/oi) { 
    14         $domains->{$1}++; 
     13    if ($line =~ /^$ip/o) { 
     14        $addr->{$1}++; 
    1515    } 
    1616} 
    1717 
    18 foreach my $key (keys %$domains) { 
    19     print $key, "\t", $domains->{$key}, "\n"; 
     18foreach my $key (keys %$addr) { 
     19    print $key, "\t", $addr->{$key}, "\n"; 
    2020} 
Note: See TracChangeset for help on using the changeset viewer.