print $fields[0], " ", $row if exists $hash{$fields[0]}; #### my %hash=(); open (my $fh,'<',$file2) or die $!; while(my $line=<$fh>) { chomp $line; # Split the line into fields (first field is the key) my @fields = split /\|/, $line; # store the entire line in the hash under the key $hash{$fields[0]} = $line; } close $fh; print "KEYS AND RECORDS ARE:\n"; print Dumper(\%hash); #### print $hash{$fields[0]}, " ", $row if exists $hash{$fields[0]};