Modify a perl script to find and count

Hello all !I have two sets of folders that have IP address from two sources.The below perl script I was working with needs some corrections.I am looking for the perl script to identify and count what IP address are found to be duplicated between both files.The format from both files are the same meaning IP addresses100.100.100.2
I am hopefull to get a report like so:
The report should contain a list of objects found in both datasets. For example:

"The following objects were found in both file A and File B:
10.1.1.1
10.2.2.1

With what I have I noticeing an error off the bat. Mind you I am not an expert in perl

syntax error at E:\dup2.pl line 10, near "print"Execution of E:\dup2.pl aborted due to compilation errors.
Thanks

#!perl

@ARGV=<E://rich//file-A-obj_prof.out.txt E://rich2//File-B-obj_prof-out.txt *>;
while( <> ){
next if /^#/;
print if $count{(split)[-1]}{$ARGV}++;
}
my %in;
push @{$in{join' and ',sort keys %{$count{$_}}}},$_ for sort grep{%{$count{$}} > 1} keys %count
print join"\n","the following files appear in $_",@{$in{$
}},"" for keys %in;

You might need a semi-colon at the end of line #9.

Assuming your file parsing bits are good, maybe this will work:

#!perl

my @dups;
my %seen;
@ARGV = ('E://rich//file-A-obj_prof.out.txt', 'E://rich2//File-B-obj_prof-out.txt');
while( <> ){
   next if /^#/;
   chomp;
   my $ip = (split)[-1];
   push @dups, $ip if (++$seen{$ip} == 2);    
}
for (sort @dups) {
   print "$_\n";
}

OK, it works !

But can it have a count or some words at the bottom that like

"The following objects were found in both file A and File B:
10.1.1.1
10.2.2.1

I am sure you could. What have you tried so far to solve that requirement?