#! /usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my $in1 = 'data1.txt'; my $in2 = 'data2.txt'; # fill hashes (quick and dirty!!!) my %hash1 = map { chomp; split m{;}, $_, 2 } grep { ! /^Kuerzel/ } do { open my $fh, '<', $in1; <$fh> }; my %hash2 = map { chomp; split m{;}, $_, 2 } grep { ! /^Kuerzel/ } do { open my $fh, '<', $in2; <$fh> }; # fill result hash; entries of hash2 OVERWRITE those from hash1 my %result = ( %hash1, %hash2 ); # check data print Dumper( \%hash1, \%hash2, \%result ); __END__ Content of data files * data1.txt: Kuerzel;Gesetz ABC;abc DEF;def GHI;ghi * data2.txt Kuerzel;Gesetz ABC;123 JKL;jkl Script's result (with comment of the source): $VAR1 = { 'ABC' => 'abc', 'DEF' => 'def', 'GHI' => 'ghi' }; $VAR2 = { 'ABC' => '123', 'JKL' => 'jkl' }; $VAR3 = { 'ABC' => '123', # overwritten by data from data2 'DEF' => 'def', # from data1 'JKL' => 'jkl', # from data2 'GHI' => 'ghi' # from data1 };