#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @files = @ARGV; my %people; for my $file (@files) { open my $fh, '<', $file or die $!; <$fh>; # Skip the header line. while (<$fh>) { chomp; my ($name, $job, $city, $state) = split /,\s*/; @{ $people{$name}{$file} }{qw{ job city state }} = ($job, $city, $state); } } for my $person (keys %people) { my $facts = $people{$person}; my @changes; for my $fact (qw( job city state )) { push @changes, $fact if ($facts->{ $files[0] }{$fact} // "") ne ($facts->{ $files[1] }{$fact} // ""); } say "$person =>", map {; " $_ Prev: ", $facts->{ $files[0] }{$_} // '-', ' Now: ', $facts->{ $files[1] }{$_} // '-' } @changes if @changes; }