my $file = 'datei.txt'; my %hash; open(FILE, "<$file") || die "Fehler: $!\n\n"; while (my $Line = ) { chomp $Line; if ($Line =~/^(\w+)\s+(\w+)(\s*#.*)?$/g) { $hash{$1}=$2; } else { next; } } close FILE;