I am trying to code a perl program to compare the "parts of speech" tags of two text files and print the matched tags along with the corresponding words in a separate file in Windows. 

```
File1:
boy N
went V
loves V
girl N
File2:
boy N
swims V
girl N
loves V

```

The expected output:
 boy N N
 girl N N
 loves V V

The columns are separated by tabs. The coding I did so far:

```
use strict;
use warnings;

my $filename = 'file1.txt';
open(my $fh, $filename)
  or die "Could not open file '$filename'";

while (my $row = <$fh>) {
  chomp $row;
  print "$row\n";
}
my $tagfile = 'file2.txt';
open(my $tg, $tagfile)
  or die "Could not open file '$filename'";
while (my $row = <$tg>) {
    chomp $row;
    print "$row\n";
    } 

```