use strict; use warnings; use constant { FILE_A => './kma', FILE_B => './kma2', }; my %a_hash; my @a_array; my @b_array; open my $a_fh, "<", FILE_A; while (<$a_fh>) { chomp; my ($key, $value) = split '=', $_, 2; $a_hash{$key} = $value; } open my $b_fh, "<", FILE_B; while (<$b_fh>) { chomp; my ($key, $value) = split '=', $_, 2; $a_hash{$key} = $value; } open my $c_fh, ">", FILE_A or die $!; print $c_fh "$_=$a_hash{$_}\n" for (keys %a_hash);