in reply to hash question

With regards to your I get nothing just a blank cursor question: The first
my $line=<>;
reads the first line of the first file. Then the loop
while($line=<>){ ... }
reads ALL the remaining lines in the files. By the time it gets to
my $line2=<>;it has exhausted the files, and it reads from stadard-input. <CTRL>D passes end-of-file to standard-input (by default) but that is probably not what you want. If you want each loop to be read for each file then it is probably easier to explicitly open the files instead. You could instead detect when the first file is closed and the second one opened using $ARGV, but that would be messy.