#!/usr/bin/perl
#================================================================================================================
#Author:huangyunhao
#Date:2010-12-10
#Function:count the number of the same lines between two lines containing a IP every line and the IP number in every file.
#Usage:perl two_files_insect.pl <flie1> <file2>
#================================================================================================================
use strict;
use warnings;
my %hash;
my $line_n=0;
open(FILE,'<',$ARGV[0]) || die "Cannot open $ARGV[0]:$!";
while(<FILE>){
$line_n++;
chomp;
$hash{$_}=1;
}
close FILE;
print "The IP number in the first file:$line_n/n";
$line_n=0;
my $number=0;
open(FILE,'<',$ARGV[1]) || die "Cannot open $ARGV[1]:$!";
while(<FILE>){
$line_n++;
chomp;
$number++ if(exists $hash{$_});
}
close FILE;
print "The IP number in the second file:$line_n/n";
print "The number of same IP:$number/n";