#!/usr/bin/perl use strict; use warnings; my $hfgwrt_file='hfgwrtnew.txt'; my $lexikon_file='bosslexikon.txt'; my $out_file='out.txt'; my %bossgra=(); open(my $lfh, '<', $lexikon_file) || err_open($lexikon_file); while (<$lfh>) { chomp; my ($bossgra, $bosspho) = split /\t/, $_; $bossgra{$bossgra}=$bosspho; } close($lfh); open(my $infh, '<', $hfgwrt_file) || err_open($hfgwrt_file); open(my $ohf, '>', $out_file) || err_open($out_file); while(my $hfgwrt=<$infh>) { chomp($hfgwrt); if(my $bosspho=$bossgra{$hfgwrt}) { print $ohf "$hfgwrt\t$bosspho\n"; } } close($ohf); close($infh); sub err_open { my $file=shift; die "Datei $file konnte nicht geƶffnet werden! ($!)\n"; }