use strict;
use warnings;
use Cwd;
my $dir = cwd;
my %count;
print "\nEnter 1st File Name :--> \t";   ## Give 1st File Name.
chomp(my $file1 = <STDIN>);
print "\nEnter 2st File Name :--> \t";  ## Give 2nd File Name.
chomp(my $file2 = <STDIN>);  
print "\nEnter File Name For Creating Report:--> \t";
chomp(my $s = <STDIN>);
unless ($file1 && $file2 && $s) {
  die "Usage: perl scriptname.pl <file1> <file2> <outputfile>\n";
}
open MARGIN, ">", $s or die "Please Close $s File And Run Again: $!";
for ($file1,$file2) {
  open IN, "<", $_ or die "File $_ not found: $!";
  while (<IN>) {
     print MARGIN;
     my $ip = (split(/,/))[0];
     $count{$ip}++;
  }
  close IN or die "Can't close input file: $!";
}
print MARGIN "\n\n";
foreach my $ip (sort {$count{$a} <=> $count{$b}} keys %count) {
  print MARGIN "$ip --> $count{$ip}\n";
}
close MARGIN;
print "\nFile has Created in $dir/$s\n";

